Text  |   XML   |   Visible Warnings:

Irssi : Irssi analysis 1 : Null Test After Dereference  at statusbar.c:500

Categories: LANG.STRUCT.NTAD
Warning ID: 2387.2398
Procedure: statusbar_create
Trace: View
Modified: Wed Sep 2 12:23:18 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     
LineSource
  /u1/paul/SATE/2010/c/irssi/irssi-0.8.14/src/fe-text/statusbar.c
  Enter statusbar_create
458 STATUSBAR_REC *statusbar_create(STATUSBAR_GROUP_REC *group,
459                                 STATUSBAR_CONFIG_REC *config,
460                                 MAIN_WINDOW_REC *parent_window) 
461 {
462         STATUSBAR_REC *bar;
463         THEME_REC *theme;
464         GSList *tmp;
465         char *name, *value;
466  
467         g_return_val_if_fail(group != NULL, NULL);
468         g_return_val_if_fail(config != NULL, NULL);
469         g_return_val_if_fail(config->type != STATUSBAR_TYPE_WINDOW ||
470                              parent_window != NULL, NULL);
471  
472         bar = g_new0(STATUSBAR_REC, 1);
473         group->bars = g_slist_append(group->bars, bar);
474  
475         bar->group = group;
476  
477         bar->config = config;
478         bar->parent_window = parent_window;
479  
480         irssi_set_dirty();
481         bar->dirty = TRUE;
482         bar->dirty_xpos = 0;
483  
484         signal_remove("terminal resized", (SIGNAL_FUNC) sig_terminal_resized);   /* Dangerous Function Cast (ID: 1957.1957) */
485         signal_remove("mainwindow resized", (SIGNAL_FUNC) sig_mainwindow_resized);   /* Dangerous Function Cast (ID: 1956.1956) */
486         signal_remove("mainwindow moved", (SIGNAL_FUNC) sig_mainwindow_resized);   /* Dangerous Function Cast (ID: 1955.1955) */
487  
488         if (config->type == STATUSBAR_TYPE_ROOT) {
489                 /* top/bottom of the screen */ 
490                 mainwindows_reserve_lines(config->placement == STATUSBAR_TOP,
491                                           config->placement == STATUSBAR_BOTTOM);
492                 theme = current_theme;
493         } else {
494                 /* top/bottom of the window */ 
495                 parent_window->statusbars = 
496                         g_slist_append(parent_window->statusbars, bar);
497                 mainwindow_set_statusbar_lines(parent_window,
498                                                config->placement == STATUSBAR_TOP,
499                                                config->placement == STATUSBAR_BOTTOM);
500                 theme = parent_window != NULL && parent_window->active != NULL &&     /* Null Test After Dereference */
501                         parent_window->active->theme != NULL ? 
502                         parent_window->active->theme : current_theme;
503         }
504  
505         signal_add("terminal resized", (SIGNAL_FUNC) sig_terminal_resized);   /* Dangerous Function Cast (ID: 1954.1954) */
506         signal_add("mainwindow resized", (SIGNAL_FUNC) sig_mainwindow_resized);   /* Dangerous Function Cast (ID: 1953.1953) */
507         signal_add("mainwindow moved", (SIGNAL_FUNC) sig_mainwindow_resized);   /* Dangerous Function Cast (ID: 1952.1952) */
508  
509         /* get background color from sb_background abstract */ 
510         name = g_strdup_printf("{sb_%s_bg}", config->name);
511         value = theme_format_expand(theme, name);
512         g_free(name);
513  
514         if (*value == '\0') {   /* Null Pointer Dereference (ID: 2388.2400) */
515                 /* try with the statusbar group name */ 
516                 g_free(value);
517  
518                 name = g_strdup_printf("{sb_%s_bg}", group->name);
519                 value = theme_format_expand(theme, name);
520                 g_free(name);
521  
522                 if (*value == '\0') {   /* Null Pointer Dereference (ID: 2388.2399) */
523                         /* fallback to default statusbar background 
524                            (also provides backwards compatibility..) */ 
525                         g_free(value);
526                         value = theme_format_expand(theme, "{sb_background}");
527                 }
528         }
529  
530         if (*value == '\0') {
531                 g_free(value);
532                 value = g_strdup("%8");
533         }
534         bar->color = g_strconcat("%n", value, NULL);
535         g_free(value);
536  
537         statusbars_recalc_ypos(bar);
538         signal_emit("statusbar created", 1, bar);
539  
540         /* create the items to statusbar */ 
541         for (tmp = config->items; tmp != NULL; tmp = tmp->next) {
542                 SBAR_ITEM_CONFIG_REC *rec = tmp->data;
543  
544                 statusbar_item_create(bar, rec);
545         }
546         return bar;
547 




Change Warning 2387.2398 : Null Test After Dereference

Priority:
State:
Finding:
Owner:
Note: