aboutsummaryrefslogtreecommitdiffstats
path: root/src/image.c
diff options
context:
space:
mode:
authorStefan Kangas2024-07-15 15:17:16 +0200
committerStefan Kangas2024-07-16 04:12:35 +0200
commitfcb4d89aaa7bf3ed77aaa4d6d5047a0ec2ed9225 (patch)
treeb0194ea40f9d809c6fd665a2b9a244266ee1317d /src/image.c
parent72ba45e2749df8561fe93bafdefbdc8eca56571f (diff)
downloademacs-fcb4d89aaa7bf3ed77aaa4d6d5047a0ec2ed9225.tar.gz
emacs-fcb4d89aaa7bf3ed77aaa4d6d5047a0ec2ed9225.zip
Prefer `memcpy` to `strcpy` in image.c
* src/image.c (lookup_image, xpm_cache_color) (imagemagick_create_cache): Prefer 'memcpy' to 'strcpy'.
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/image.c b/src/image.c
index b77c12b4cbc..90e6312e128 100644
--- a/src/image.c
+++ b/src/image.c
@@ -3525,8 +3525,9 @@ lookup_image (struct frame *f, Lisp_Object spec, int face_id)
3525 img->face_font_size = font_size; 3525 img->face_font_size = font_size;
3526 img->face_font_height = face->font->height; 3526 img->face_font_height = face->font->height;
3527 img->face_font_width = face->font->average_width; 3527 img->face_font_width = face->font->average_width;
3528 img->face_font_family = xmalloc (strlen (font_family) + 1); 3528 size_t len = strlen (font_family) + 1;
3529 strcpy (img->face_font_family, font_family); 3529 img->face_font_family = xmalloc (len);
3530 memcpy (img->face_font_family, font_family, len);
3530 img->load_failed_p = ! img->type->load_img (f, img); 3531 img->load_failed_p = ! img->type->load_img (f, img);
3531 3532
3532 /* If we can't load the image, and we don't have a width and 3533 /* If we can't load the image, and we don't have a width and
@@ -5544,15 +5545,13 @@ xpm_color_bucket (char *color_name)
5544static struct xpm_cached_color * 5545static struct xpm_cached_color *
5545xpm_cache_color (struct frame *f, char *color_name, XColor *color, int bucket) 5546xpm_cache_color (struct frame *f, char *color_name, XColor *color, int bucket)
5546{ 5547{
5547 size_t nbytes;
5548 struct xpm_cached_color *p;
5549
5550 if (bucket < 0) 5548 if (bucket < 0)
5551 bucket = xpm_color_bucket (color_name); 5549 bucket = xpm_color_bucket (color_name);
5552 5550
5553 nbytes = FLEXSIZEOF (struct xpm_cached_color, name, strlen (color_name) + 1); 5551 size_t len = strlen (color_name) + 1;
5554 p = xmalloc (nbytes); 5552 size_t nbytes = FLEXSIZEOF (struct xpm_cached_color, name, len);
5555 strcpy (p->name, color_name); 5553 struct xpm_cached_color *p = xmalloc (nbytes);
5554 memcpy (p->name, color_name, len);
5556 p->color = *color; 5555 p->color = *color;
5557 p->next = xpm_color_cache[bucket]; 5556 p->next = xpm_color_cache[bucket];
5558 xpm_color_cache[bucket] = p; 5557 xpm_color_cache[bucket] = p;
@@ -10867,13 +10866,13 @@ static struct animation_cache *animation_cache = NULL;
10867static struct animation_cache * 10866static struct animation_cache *
10868imagemagick_create_cache (char *signature) 10867imagemagick_create_cache (char *signature)
10869{ 10868{
10869 size_t len = strlen (signature) + 1;
10870 struct animation_cache *cache 10870 struct animation_cache *cache
10871 = xmalloc (FLEXSIZEOF (struct animation_cache, signature, 10871 = xmalloc (FLEXSIZEOF (struct animation_cache, signature, len));
10872 strlen (signature) + 1));
10873 cache->wand = 0; 10872 cache->wand = 0;
10874 cache->index = 0; 10873 cache->index = 0;
10875 cache->next = 0; 10874 cache->next = 0;
10876 strcpy (cache->signature, signature); 10875 memcpy (cache->signature, signature, len);
10877 return cache; 10876 return cache;
10878} 10877}
10879 10878