|
Lines 1079-1085
Link Here
|
| 1079 |
gint key = 0; |
1079 |
gint key = 0; |
| 1080 |
gint current_key = 1; |
1080 |
gint current_key = 1; |
| 1081 |
gint space = 128; |
1081 |
gint space = 128; |
| 1082 |
gchar word[128], color[128], current_color[128]; |
1082 |
gchar word[129], color[129], current_color[129]; |
| 1083 |
gchar *r; |
1083 |
gchar *r; |
| 1084 |
|
1084 |
|
| 1085 |
word[0] = '\0'; |
1085 |
word[0] = '\0'; |
|
Lines 1121-1128
Link Here
|
| 1121 |
return NULL; |
1121 |
return NULL; |
| 1122 |
/* accumulate color name */ |
1122 |
/* accumulate color name */ |
| 1123 |
if (color[0] != '\0') { |
1123 |
if (color[0] != '\0') { |
| 1124 |
strcat (color, " "); |
1124 |
strncat (color, " ", space); |
| 1125 |
space--; |
1125 |
space -= MIN (space, 1); |
| 1126 |
} |
1126 |
} |
| 1127 |
strncat (color, word, space); |
1127 |
strncat (color, word, space); |
| 1128 |
space -= MIN (space, strlen (word)); |
1128 |
space -= MIN (space, strlen (word)); |
|
Lines 1246-1272
Link Here
|
| 1246 |
return NULL; |
1246 |
return NULL; |
| 1247 |
|
1247 |
|
| 1248 |
} |
1248 |
} |
| 1249 |
if (n_col <= 0) { |
1249 |
if (cpp <= 0 || cpp >= 32) { |
| 1250 |
g_set_error (error, |
1250 |
g_set_error (error, |
| 1251 |
GDK_PIXBUF_ERROR, |
1251 |
GDK_PIXBUF_ERROR, |
| 1252 |
GDK_PIXBUF_ERROR_CORRUPT_IMAGE, |
1252 |
GDK_PIXBUF_ERROR_CORRUPT_IMAGE, |
| 1253 |
_("XPM file has invalid number of colors")); |
1253 |
_("XPM has invalid number of chars per pixel")); |
| 1254 |
return NULL; |
1254 |
return NULL; |
| 1255 |
|
|
|
| 1256 |
} |
1255 |
} |
| 1257 |
if (cpp <= 0 || cpp >= 32) { |
1256 |
if (n_col <= 0 || n_col >= G_MAXSIZE / (cpp + 1)) { |
| 1258 |
g_set_error (error, |
1257 |
g_set_error (error, |
| 1259 |
GDK_PIXBUF_ERROR, |
1258 |
GDK_PIXBUF_ERROR, |
| 1260 |
GDK_PIXBUF_ERROR_CORRUPT_IMAGE, |
1259 |
GDK_PIXBUF_ERROR_CORRUPT_IMAGE, |
| 1261 |
_("XPM has invalid number of chars per pixel")); |
1260 |
_("XPM file has invalid number of colors")); |
| 1262 |
return NULL; |
1261 |
return NULL; |
| 1263 |
} |
1262 |
} |
| 1264 |
|
1263 |
|
| 1265 |
/* The hash is used for fast lookups of color from chars */ |
1264 |
/* The hash is used for fast lookups of color from chars */ |
| 1266 |
color_hash = g_hash_table_new (g_str_hash, g_str_equal); |
1265 |
color_hash = g_hash_table_new (g_str_hash, g_str_equal); |
| 1267 |
|
1266 |
|
| 1268 |
name_buf = g_new (gchar, n_col * (cpp + 1)); |
1267 |
name_buf = g_try_malloc (n_col * (cpp + 1)); |
| 1269 |
colors = g_new (XPMColor, n_col); |
1268 |
if (!name_buf) { |
|
|
1269 |
g_set_error (error, |
| 1270 |
GDK_PIXBUF_ERROR, |
| 1271 |
GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY, |
| 1272 |
_("Cannot allocate memory for loading XPM image")); |
| 1273 |
g_hash_table_destroy (color_hash); |
| 1274 |
return NULL; |
| 1275 |
} |
| 1276 |
colors = (XPMColor *) g_try_malloc (sizeof (XPMColor) * n_col); |
| 1277 |
if (!colors) { |
| 1278 |
g_set_error (error, |
| 1279 |
GDK_PIXBUF_ERROR, |
| 1280 |
GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY, |
| 1281 |
_("Cannot allocate memory for loading XPM image")); |
| 1282 |
g_hash_table_destroy (color_hash); |
| 1283 |
g_free (name_buf); |
| 1284 |
return NULL; |
| 1285 |
} |
| 1286 |
g_print ("n_col %d name_buf %p (%d) colors %p (%d)\n", |
| 1287 |
n_col, name_buf, n_col * (cpp + 1), colors, sizeof (XPMColor) * n_col); |
| 1270 |
|
1288 |
|
| 1271 |
for (cnt = 0; cnt < n_col; cnt++) { |
1289 |
for (cnt = 0; cnt < n_col; cnt++) { |
| 1272 |
gchar *color_name; |
1290 |
gchar *color_name; |