avoid segfault

This commit is contained in:
Axel Kohlmeyer 2020-01-22 12:41:59 -05:00
parent 64a4bf6a42
commit a87c7a4a53
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
1 changed files with 6 additions and 4 deletions

View File

@ -1466,10 +1466,12 @@ double *Image::color2rgb(const char *color, int index)
return userrgb[-index-1];
}
for (int i = 0; i < ncolors; i++)
if (strcmp(color,username[i]) == 0) return userrgb[i];
for (int i = 0; i < NCOLORS; i++)
if (strcmp(color,name[i]) == 0) return rgb[i];
if (color) {
for (int i = 0; i < ncolors; i++)
if (strcmp(color,username[i]) == 0) return userrgb[i];
for (int i = 0; i < NCOLORS; i++)
if (strcmp(color,name[i]) == 0) return rgb[i];
}
return NULL;
}