diff options
| author | YAMAMOTO Mitsuharu | 2005-10-25 08:12:44 +0000 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2005-10-25 08:12:44 +0000 |
| commit | de297941ce40873d2ea0dc1babc1d37292416520 (patch) | |
| tree | 34b0b13696b0374980c2b5519ed6f97f9ef7062f /src | |
| parent | f77b652537e427472e24a0ba92c547373958e46f (diff) | |
| download | emacs-de297941ce40873d2ea0dc1babc1d37292416520.tar.gz emacs-de297941ce40873d2ea0dc1babc1d37292416520.zip | |
[MAC_OS] (image_load_qt_1): Check image size.
Use GraphicsImportGetImageDescription instead of
GraphicsImportGetNaturalBounds.
[MAC_OSX] (image_load_quartz2d): Check image size.
[MAC_OS] (xpm_load_image): Likewise.
Diffstat (limited to 'src')
| -rw-r--r-- | src/image.c | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/src/image.c b/src/image.c index 1996d8477e9..fb3cdecaa54 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -2291,6 +2291,7 @@ image_load_qt_1 (f, img, type, fss, dh) | |||
| 2291 | GraphicsImportComponent gi; | 2291 | GraphicsImportComponent gi; |
| 2292 | Rect rect; | 2292 | Rect rect; |
| 2293 | int width, height; | 2293 | int width, height; |
| 2294 | ImageDescriptionHandle desc_handle; | ||
| 2294 | short draw_all_pixels; | 2295 | short draw_all_pixels; |
| 2295 | Lisp_Object specified_bg; | 2296 | Lisp_Object specified_bg; |
| 2296 | XColor color; | 2297 | XColor color; |
| @@ -2326,14 +2327,22 @@ image_load_qt_1 (f, img, type, fss, dh) | |||
| 2326 | goto error; | 2327 | goto error; |
| 2327 | } | 2328 | } |
| 2328 | } | 2329 | } |
| 2329 | err = GraphicsImportGetNaturalBounds (gi, &rect); | 2330 | err = GraphicsImportGetImageDescription (gi, &desc_handle); |
| 2330 | if (err != noErr) | 2331 | if (err != noErr || desc_handle == NULL) |
| 2331 | { | 2332 | { |
| 2332 | image_error ("Error reading `%s'", img->spec, Qnil); | 2333 | image_error ("Error reading `%s'", img->spec, Qnil); |
| 2333 | goto error; | 2334 | goto error; |
| 2334 | } | 2335 | } |
| 2335 | width = img->width = rect.right - rect.left; | 2336 | width = img->width = (*desc_handle)->width; |
| 2336 | height = img->height = rect.bottom - rect.top; | 2337 | height = img->height = (*desc_handle)->height; |
| 2338 | DisposeHandle ((Handle)desc_handle); | ||
| 2339 | |||
| 2340 | if (!check_image_size (f, width, height)) | ||
| 2341 | { | ||
| 2342 | image_error ("Invalid image size", Qnil, Qnil); | ||
| 2343 | goto error; | ||
| 2344 | } | ||
| 2345 | |||
| 2337 | err = GraphicsImportDoesDrawAllPixels (gi, &draw_all_pixels); | 2346 | err = GraphicsImportDoesDrawAllPixels (gi, &draw_all_pixels); |
| 2338 | #if 0 | 2347 | #if 0 |
| 2339 | /* Don't check the error code here. It may have an undocumented | 2348 | /* Don't check the error code here. It may have an undocumented |
| @@ -2535,6 +2544,15 @@ image_load_quartz2d (f, img, png_p) | |||
| 2535 | image_error ("Error reading image `%s'", img->spec, Qnil); | 2544 | image_error ("Error reading image `%s'", img->spec, Qnil); |
| 2536 | return 0; | 2545 | return 0; |
| 2537 | } | 2546 | } |
| 2547 | width = img->width = CGImageGetWidth (image); | ||
| 2548 | height = img->height = CGImageGetHeight (image); | ||
| 2549 | |||
| 2550 | if (!check_image_size (f, width, height)) | ||
| 2551 | { | ||
| 2552 | UNGCPRO; | ||
| 2553 | image_error ("Invalid image size", Qnil, Qnil); | ||
| 2554 | return 0; | ||
| 2555 | } | ||
| 2538 | 2556 | ||
| 2539 | if (png_p) | 2557 | if (png_p) |
| 2540 | { | 2558 | { |
| @@ -2548,8 +2566,7 @@ image_load_quartz2d (f, img, png_p) | |||
| 2548 | color.blue = BLUE16_FROM_ULONG (color.pixel); | 2566 | color.blue = BLUE16_FROM_ULONG (color.pixel); |
| 2549 | } | 2567 | } |
| 2550 | } | 2568 | } |
| 2551 | width = img->width = CGImageGetWidth (image); | 2569 | |
| 2552 | height = img->height = CGImageGetHeight (image); | ||
| 2553 | if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) | 2570 | if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) |
| 2554 | { | 2571 | { |
| 2555 | CGImageRelease (image); | 2572 | CGImageRelease (image); |
| @@ -4190,6 +4207,13 @@ xpm_load_image (f, img, contents, end) | |||
| 4190 | || width <= 0 || height <= 0 | 4207 | || width <= 0 || height <= 0 |
| 4191 | || num_colors <= 0 || chars_per_pixel <= 0) | 4208 | || num_colors <= 0 || chars_per_pixel <= 0) |
| 4192 | goto failure; | 4209 | goto failure; |
| 4210 | |||
| 4211 | if (!check_image_size (f, width, height)) | ||
| 4212 | { | ||
| 4213 | image_error ("Invalid image size", Qnil, Qnil); | ||
| 4214 | goto failure; | ||
| 4215 | } | ||
| 4216 | |||
| 4193 | expect (','); | 4217 | expect (','); |
| 4194 | 4218 | ||
| 4195 | XSETFRAME (frame, f); | 4219 | XSETFRAME (frame, f); |