Text  |   XML   |   Visible Warnings:

irssi-0.8.14 : irssi-0.8.14 analysis 2 : Division By Zero  at mainwindows-layout.c:155

Categories: LANG.ARITH.DIVZERO CWE:369
Warning ID: 7443.28550
Procedure: sig_layout_restore
Trace: view
Modified: Thu Nov 26 11:21:04 2009   show details
 
Priority: None
State: None
Finding: None
Owner: None
  edit properties

Legend [ X ]
Warning Location
Contributes
Parse Error
Other Warning
Two or More Loop Iterations
On Execution Path
Comment
Macro
Preprocessor
Include
Keyword
Preprocessed Away

Source  |  Language: C Hide Legend     
ProblemLineSource
   /kat0/fletcher/SATE/2010/irssi-0.8.14/src/fe-text/mainwindows-layout.c
   Enter sig_layout_restore
 111 static void sig_layout_restore(void) 
 112 {
 113         MAIN_WINDOW_REC *lower_window;
 114         WINDOW_REC *window;
 115         CONFIG_NODE *node;
 116         GSList *tmp, *sorted_config;
 117         int avail_height, height, *heights;
 118         int i, lower_size, windows_count, diff;
 119  
 120         node = iconfig_node_traverse("mainwindows", FALSE);
 121         if (node == NULL) return;
 122  
 123         sorted_config = get_sorted_windows_config(node);
 124         windows_count = g_slist_length(sorted_config);
 125  
 126         /* calculate the saved terminal height */ 
 127         avail_height = term_height - 
 128                 screen_reserved_top - screen_reserved_bottom;
true129         height = 0;
 130         heights = g_new0(int, windows_count);
 131         for (i = 0, tmp = sorted_config; tmp != NULL; tmp = tmp->next, i++) {
 132                 CONFIG_NODE *node = tmp->data;
 133  
 134                 heights[i] = config_node_get_int(node, "lines", 0);
 135                 height += heights[i];
 136         }
 137  
 138         if (avail_height <= (WINDOW_MIN_SIZE*2)+1) {
 139                 /* we can fit only one window to screen -
 140                    give it all the height we can */ 
 141                 windows_count = 1;
 142                 heights[0] = avail_height;
 143         } else if (height != avail_height) {
 144                 /* Terminal's height is different from the saved one.
 145                    Resize the windows so they fit to screen. */ 
 146                 while (height > avail_height &&
 147                        windows_count*(WINDOW_MIN_SIZE+1) > avail_height) {
 148                         /* all windows can't fit into screen,
 149                            remove the lowest ones */ 
 150                         windows_count--;
 151                 }
 152  
 153                 /* try to keep the windows' size about the same in percents */ 
 154                 for (i = 0; i < windows_count; i++) {
height = 0155                         int size = avail_height*heights[i]/height;     /* Division By Zero */
Preconditions
&$unknown_2183187 = 4 * &$unknown_2183189
&$unknown_2183187 >= 4
&$unknown_2183188 >= 6
&$unknown_2183189 >= 1
*((char*)$unknown_2183185)[8] = 4
Postconditions
avail_height' = &$unknown_2183188
height' = 0
i' = 0
node' = &$unknown_2183185
sorted_config' = 0
tmp' = 0
windows_count' = &$unknown_2183189




Change Warning 7443.28550 : Division By Zero

Priority:
State:
Finding:
Owner:
Note: