Commit b70bb2fc3c9164d28ea0ef2dcceed6bccea6cc8a
1 parent
12e3bf67
Exists in
master
and in
5 other branches
Corrigindo segfault na impressão quando a tabela de cores está errada
Showing
2 changed files
with
19 additions
and
7 deletions
Show diff stats
src/pw3270/print.c
... | ... | @@ -395,6 +395,9 @@ static gchar * enum_to_string(GType type, guint enum_value) |
395 | 395 | { |
396 | 396 | gchar *ptr = get_string_from_config("print","colors",""); |
397 | 397 | |
398 | + trace("info->color=%p",info->color); | |
399 | + trace("colorlist=%p",ptr); | |
400 | + | |
398 | 401 | if(*ptr) |
399 | 402 | v3270_set_color_table(info->color,ptr); |
400 | 403 | else | ... | ... |
src/pw3270/v3270/widget.c
... | ... | @@ -1296,15 +1296,24 @@ void v3270_set_color_table(GdkRGBA *table, const gchar *colors) |
1296 | 1296 | |
1297 | 1297 | g_warning("Color table has %d elements; should be %d.",cnt,V3270_COLOR_COUNT); |
1298 | 1298 | |
1299 | - for(f=0;f < cnt;f++) | |
1300 | - gdk_rgba_parse(table+f,clr[f]); | |
1301 | - | |
1302 | - for(f=cnt; f < V3270_COLOR_COUNT;f++) | |
1303 | - gdk_rgba_parse(table+f,clr[cnt-1]); | |
1299 | + if(cnt < V3270_COLOR_COUNT) | |
1300 | + { | |
1301 | + // Less than the required | |
1302 | + for(f=0;f < cnt;f++) | |
1303 | + gdk_rgba_parse(table+f,clr[f]); | |
1304 | 1304 | |
1305 | - clr[V3270_COLOR_OIA_BACKGROUND] = clr[0]; | |
1306 | - clr[V3270_COLOR_SELECTED_BG] = clr[0]; | |
1305 | + for(f=cnt; f < V3270_COLOR_COUNT;f++) | |
1306 | + gdk_rgba_parse(table+f,clr[cnt-1]); | |
1307 | 1307 | |
1308 | + clr[V3270_COLOR_OIA_BACKGROUND] = clr[0]; | |
1309 | + clr[V3270_COLOR_SELECTED_BG] = clr[0]; | |
1310 | + } | |
1311 | + else | |
1312 | + { | |
1313 | + // More than required | |
1314 | + for(f=0;f < V3270_COLOR_COUNT;f++) | |
1315 | + gdk_rgba_parse(table+f,clr[f]); | |
1316 | + } | |
1308 | 1317 | } |
1309 | 1318 | |
1310 | 1319 | g_strfreev(clr); | ... | ... |