diff options
| author | Stefan Kangas | 2025-01-22 00:47:02 +0100 |
|---|---|---|
| committer | Stefan Kangas | 2025-01-22 00:49:50 +0100 |
| commit | cdcfffd50a61058b135ddca1f748a5a20a7da32e (patch) | |
| tree | 73d905acba1a850ef37e7af495d3dd0ea353d5dd /src | |
| parent | 5f108cb663a9488c587507e4f723fe1e12732945 (diff) | |
| download | emacs-cdcfffd50a61058b135ddca1f748a5a20a7da32e.tar.gz emacs-cdcfffd50a61058b135ddca1f748a5a20a7da32e.zip | |
Prefer snprintf to sprintf in image.c
* src/image.c (image_background, image_build_heuristic_mask)
(png_load_body): Prefer snprintf to sprintf.
Diffstat (limited to 'src')
| -rw-r--r-- | src/image.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/image.c b/src/image.c index 7ab6289bb2a..2b898e12805 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -1995,10 +1995,10 @@ image_background (struct image *img, struct frame *f, Emacs_Pix_Context pimg) | |||
| 1995 | #ifdef USE_CAIRO | 1995 | #ifdef USE_CAIRO |
| 1996 | { | 1996 | { |
| 1997 | char color_name[30]; | 1997 | char color_name[30]; |
| 1998 | sprintf (color_name, "#%04x%04x%04x", | 1998 | snprintf (color_name, sizeof color_name, "#%04x%04x%04x", |
| 1999 | (unsigned int) RED16_FROM_ULONG (bg), | 1999 | (unsigned int) RED16_FROM_ULONG (bg), |
| 2000 | (unsigned int) GREEN16_FROM_ULONG (bg), | 2000 | (unsigned int) GREEN16_FROM_ULONG (bg), |
| 2001 | (unsigned int) BLUE16_FROM_ULONG (bg)); | 2001 | (unsigned int) BLUE16_FROM_ULONG (bg)); |
| 2002 | bg = image_alloc_image_color (f, img, build_string (color_name), 0); | 2002 | bg = image_alloc_image_color (f, img, build_string (color_name), 0); |
| 2003 | } | 2003 | } |
| 2004 | #endif | 2004 | #endif |
| @@ -7386,8 +7386,8 @@ image_build_heuristic_mask (struct frame *f, struct image *img, | |||
| 7386 | { | 7386 | { |
| 7387 | #ifndef USE_CAIRO | 7387 | #ifndef USE_CAIRO |
| 7388 | char color_name[30]; | 7388 | char color_name[30]; |
| 7389 | sprintf (color_name, "#%04x%04x%04x", | 7389 | snprintf (color_name, sizeof color_name, "#%04x%04x%04x", |
| 7390 | rgb[0] + 0u, rgb[1] + 0u, rgb[2] + 0u); | 7390 | rgb[0] + 0u, rgb[1] + 0u, rgb[2] + 0u); |
| 7391 | bg = ( | 7391 | bg = ( |
| 7392 | #ifdef HAVE_NTGUI | 7392 | #ifdef HAVE_NTGUI |
| 7393 | 0x00ffffff & /* Filter out palette info. */ | 7393 | 0x00ffffff & /* Filter out palette info. */ |
| @@ -8537,7 +8537,8 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) | |||
| 8537 | img->background = lookup_rgb_color (f, bg->red, bg->green, bg->blue); | 8537 | img->background = lookup_rgb_color (f, bg->red, bg->green, bg->blue); |
| 8538 | #else /* USE_CAIRO */ | 8538 | #else /* USE_CAIRO */ |
| 8539 | char color_name[30]; | 8539 | char color_name[30]; |
| 8540 | sprintf (color_name, "#%04x%04x%04x", bg->red, bg->green, bg->blue); | 8540 | snprintf (color_name, sizeof color_name, "#%04x%04x%04x", |
| 8541 | bg->red, bg->green, bg->blue); | ||
| 8541 | img->background | 8542 | img->background |
| 8542 | = image_alloc_image_color (f, img, build_string (color_name), 0); | 8543 | = image_alloc_image_color (f, img, build_string (color_name), 0); |
| 8543 | #endif /* USE_CAIRO */ | 8544 | #endif /* USE_CAIRO */ |