diff options
| author | Po Lu | 2024-07-24 11:57:28 +0800 |
|---|---|---|
| committer | Po Lu | 2024-07-24 11:57:28 +0800 |
| commit | b5543c54bf08c4fa4cae6b7f404a37a2aee60cdf (patch) | |
| tree | 6d150521a85d178acd21593c7e32ab9c8841b4a9 /src | |
| parent | 1ee8579eb7d7aae9405f33099559ac8205a59be2 (diff) | |
| download | emacs-b5543c54bf08c4fa4cae6b7f404a37a2aee60cdf.tar.gz emacs-b5543c54bf08c4fa4cae6b7f404a37a2aee60cdf.zip | |
Fix NULL pointer dereferences in xpm_load_image
* src/image.c (x_destroy_x_image): Correct test condition.
(xpm_load_image): Do not release image data if it is still to be
created.
Diffstat (limited to 'src')
| -rw-r--r-- | src/image.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/image.c b/src/image.c index 5aabb517f30..f869a95c15d 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -3886,7 +3886,7 @@ x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth, | |||
| 3886 | static void | 3886 | static void |
| 3887 | x_destroy_x_image (XImage *ximg) | 3887 | x_destroy_x_image (XImage *ximg) |
| 3888 | { | 3888 | { |
| 3889 | if (ximg) | 3889 | if (ximg->data) |
| 3890 | { | 3890 | { |
| 3891 | xfree (ximg->data); | 3891 | xfree (ximg->data); |
| 3892 | ximg->data = NULL; | 3892 | ximg->data = NULL; |
| @@ -6505,9 +6505,12 @@ xpm_load_image (struct frame *f, | |||
| 6505 | 6505 | ||
| 6506 | failure: | 6506 | failure: |
| 6507 | image_error ("Invalid XPM3 file (%s)", img->spec); | 6507 | image_error ("Invalid XPM3 file (%s)", img->spec); |
| 6508 | image_destroy_x_image (ximg); | 6508 | if (ximg) |
| 6509 | image_destroy_x_image (mask_img); | 6509 | { |
| 6510 | image_clear_image (f, img); | 6510 | image_destroy_x_image (ximg); |
| 6511 | image_destroy_x_image (mask_img); | ||
| 6512 | image_clear_image (f, img); | ||
| 6513 | } | ||
| 6511 | return 0; | 6514 | return 0; |
| 6512 | 6515 | ||
| 6513 | #undef match | 6516 | #undef match |