Prefer snprintf to sprintf in image.c
* src/image.c (image_background, image_build_heuristic_mask) (png_load_body): Prefer snprintf to sprintf.
This commit is contained in:
parent
5f108cb663
commit
cdcfffd50a
1 changed files with 8 additions and 7 deletions
15
src/image.c
15
src/image.c
|
@ -1995,10 +1995,10 @@ image_background (struct image *img, struct frame *f, Emacs_Pix_Context pimg)
|
|||
#ifdef USE_CAIRO
|
||||
{
|
||||
char color_name[30];
|
||||
sprintf (color_name, "#%04x%04x%04x",
|
||||
(unsigned int) RED16_FROM_ULONG (bg),
|
||||
(unsigned int) GREEN16_FROM_ULONG (bg),
|
||||
(unsigned int) BLUE16_FROM_ULONG (bg));
|
||||
snprintf (color_name, sizeof color_name, "#%04x%04x%04x",
|
||||
(unsigned int) RED16_FROM_ULONG (bg),
|
||||
(unsigned int) GREEN16_FROM_ULONG (bg),
|
||||
(unsigned int) BLUE16_FROM_ULONG (bg));
|
||||
bg = image_alloc_image_color (f, img, build_string (color_name), 0);
|
||||
}
|
||||
#endif
|
||||
|
@ -7386,8 +7386,8 @@ image_build_heuristic_mask (struct frame *f, struct image *img,
|
|||
{
|
||||
#ifndef USE_CAIRO
|
||||
char color_name[30];
|
||||
sprintf (color_name, "#%04x%04x%04x",
|
||||
rgb[0] + 0u, rgb[1] + 0u, rgb[2] + 0u);
|
||||
snprintf (color_name, sizeof color_name, "#%04x%04x%04x",
|
||||
rgb[0] + 0u, rgb[1] + 0u, rgb[2] + 0u);
|
||||
bg = (
|
||||
#ifdef HAVE_NTGUI
|
||||
0x00ffffff & /* Filter out palette info. */
|
||||
|
@ -8537,7 +8537,8 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
|
|||
img->background = lookup_rgb_color (f, bg->red, bg->green, bg->blue);
|
||||
#else /* USE_CAIRO */
|
||||
char color_name[30];
|
||||
sprintf (color_name, "#%04x%04x%04x", bg->red, bg->green, bg->blue);
|
||||
snprintf (color_name, sizeof color_name, "#%04x%04x%04x",
|
||||
bg->red, bg->green, bg->blue);
|
||||
img->background
|
||||
= image_alloc_image_color (f, img, build_string (color_name), 0);
|
||||
#endif /* USE_CAIRO */
|
||||
|
|
Loading…
Add table
Reference in a new issue