about summary refs log tree commit diff
path: root/lib/colorname.c
diff options
context:
space:
mode:
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);