GraphicsMagick: coders/xpm.c (ReadXPMImage): Do not waste memory...

GraphicsMagick Commits <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.10637.1667061481.1459.graphicsmagick-commit@lists.sourceforge.net>
changeset ddccc7bf8867 in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=ddccc7bf8867
summary: coders/xpm.c (ReadXPMImage): Do not waste memory with useless 0 terminator for keys.

diffstat:

 coders/xpm.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (25 lines):

diff -r ea9b8002dc3d -r ddccc7bf8867 coders/xpm.c
--- a/coders/xpm.c	Sat Oct 29 10:33:21 2022 +0200
+++ b/coders/xpm.c	Sat Oct 29 18:37:32 2022 +0200
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2020 GraphicsMagick Group
+% Copyright (C) 2003-2022 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -437,11 +437,11 @@
                               "    %lu: %s", i-1, textlist[i-1]);
     if (strlen(p) < width)
       break;
-    keys[j]=MagickAllocateResourceLimitedMemory(char *,(size_t) width+1);
+    keys[j]=MagickAllocateResourceLimitedMemory(char *,(size_t)width);
     if (keys[j] == (char *) NULL)
       ThrowXPMReaderException(ResourceLimitError,MemoryAllocationFailed,image);
-    keys[j][width]='\0';
-    (void) strncpy(keys[j],p,width);
+
+    (void) memcpy(keys[j],p,width);
     /*
       Parse color.
     */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.