about summary refs log tree commit diff
path: root/lib/colorname.c
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2018-10-02 15:10:58 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2018-10-02 15:10:58 +0000
commit2dcdf7b8850b6435cd6339f6c77a2e83f52b76f3 (patch)
treee994502a31e93005521a4d058481741fd6b7cf33 /lib/colorname.c
parent78d7ff61d197ed876cc6e0c31611d8ddcf2a1fe1 (diff)
downloadnetpbm-mirror-2dcdf7b8850b6435cd6339f6c77a2e83f52b76f3.tar.gz
netpbm-mirror-2dcdf7b8850b6435cd6339f6c77a2e83f52b76f3.tar.xz
netpbm-mirror-2dcdf7b8850b6435cd6339f6c77a2e83f52b76f3.zip
cleanup
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3372 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib/colorname.c')
-rw-r--r--lib/colorname.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/colorname.c b/lib/colorname.c
index 596d8788..9400adf7 100644
--- a/lib/colorname.c
+++ b/lib/colorname.c
@@ -200,10 +200,16 @@ pm_parse_dictionary_namen(char   const colorname[],
 
     fP = pm_openColornameFile(NULL, TRUE);  /* exits if error */
     canoncolor = strdup(colorname);
+
+    if (!canoncolor)
+        pm_error("Failed to allocate memory for %u-byte color name",
+                 (unsigned)strlen(colorname));
+
     pm_canonstr(canoncolor);
-    gotit = FALSE;
-    colorfileExhausted = FALSE;
-    while (!gotit && !colorfileExhausted) {
+
+    for(gotit = FALSE, colorfileExhausted = FALSE;
+        !gotit && !colorfileExhausted; ) {
+
         colorfileEntry = pm_colorget(fP);
         if (colorfileEntry.colorname) {
             pm_canonstr(colorfileEntry.colorname);