Commit 7f662020237763a6d56c6b6ea266836cc496fb5b

Authored by perry.werneck@gmail.com
1 parent e11da3c9
Exists in master and in 1 other branch develop

Corrigindo segfault na impressão quando a tabela de cores está errada

Showing 1 changed file with 16 additions and 7 deletions   Show diff stats
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);
... ...