Text  |   XML   |   Visible Warnings:

irssi-0.8.14 : irssi-0.8.14 analysis 2 : Null Pointer Dereference  at themes.c:379

Categories: LANG.MEM.NPD CWE:476
Warning ID: 22022.28489
Procedure: theme_format_expand_abstract
Trace: view
Modified: Thu Nov 26 11:17:28 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/perl/ui/Themes.c
   Enter XS_Irssi__UI__Theme_format_expand
 401 XS(XS_Irssi__UI__Theme_format_expand) 
 402 {
 403 #ifdef dVAR 
 404     dVAR; dXSARGS;
 405 #else 
 406     dXSARGS; 
 407 #endif 
 408     if (items < 2 || items > 3)
 409        Perl_croak(aTHX_ "Usage: %s(%s)", "Irssi::UI::Theme::format_expand", "theme, format, flags=0");
 410     PERL_UNUSED_VAR(cv); /* -W */ 
 411     PERL_UNUSED_VAR(ax); /* -Wall */ 
 412     SP -= items;
 413     {
true414         Irssi__UI__Theme        theme = irssi_ref_object(ST(0));
 415         char *  format = (char *)SvPV_nolen(ST(1));
 416         int     flags;
 417 #line 234 "Themes.xs"
 418         char *ret;
 419 #line 420 "Themes.c"
 420  
 421         if (items < 3)
 422             flags = 0;
 423         else {
 424             flags = (int)SvIV(ST(2));
 425         }
 426 #line 236 "Themes.xs"
 427         if (flags == 0) {
 428                 ret = theme_format_expand(theme, format);
 429         } else {
 430                 ret = theme_format_expand_data(theme, (const char **) &format, 'n', 'n',
theme <= 4095431                                                NULL, NULL, EXPAND_FLAG_ROOT | flags);
     /kat0/fletcher/SATE/2010/irssi-0.8.14/src/fe-common/core/themes.c
     Enter XS_Irssi__UI__Theme_format_expand / theme_format_expand_data
 435   char *theme_format_expand_data(THEME_REC *theme, const char **format,
 436                                  char default_fg, char default_bg,
 437                                  char *save_last_fg, char *save_last_bg,
 438                                  int flags) 
 439   {
 440           GString *str;
 441           char *ret, *abstract;
 442           char last_fg, last_bg;
 443           int recurse_flags;
 444    
 445           last_fg = default_fg;
 446           last_bg = default_bg;
 447           recurse_flags = flags & EXPAND_FLAG_RECURSIVE_MASK;
 448    
 449           str = g_string_new(NULL);
 450           while (**format != '\0') {
 451                   if ((flags & EXPAND_FLAG_ROOT) == 0 && **format == '}') {
 452                           /* ignore } if we're expanding original string */ 
 453                           (*format)++;
 454                           break;
 455                   }
 456    
 457                   if (**format != '{') {
 458                           if ((flags & EXPAND_FLAG_LASTCOLOR_ARG) &&
 459                               **format == '$' && (*format)[1] == '0') {
 460                                   /* save the color before $0 ..
 461                                      this is for the %n replacing */ 
 462                                   if (save_last_fg != NULL) {
 463                                           *save_last_fg = last_fg;
 464                                           save_last_fg = NULL;
 465                                   }
 466                                   if (save_last_bg != NULL) {
 467                                           *save_last_bg = last_bg;
 468                                           save_last_bg = NULL;
 469                                   }
 470                           }
 471    
 472                           theme_format_append_next(theme, str, format,
 473                                                    default_fg, default_bg,
 474                                                    &last_fg, &last_bg,
 475                                                    recurse_flags);
 476                           continue;
 477                   }
 478    
 479                   (*format)++;
 480                   if (**format == '\0' || **format == '}')
 481                           break; /* error */ 
 482    
 483                   /* get a single {...} */ 
 484                   abstract = theme_format_expand_abstract(theme, format,
 485                                                           last_fg, last_bg,
theme <= 4095486                                                           recurse_flags);
       Enter XS_Irssi__UI__Theme_format_expand / theme_format_expand_data / theme_format_expand_abstract
 344     static char *theme_format_expand_abstract(THEME_REC *theme,
 345                                               const char **formatp,
 346                                               char default_fg, char default_bg,
 347                                               int flags) 
 348     {
 349             GString *str;
 350             const char *p, *format;
 351             char *abstract, *data, *ret;
 352             int len;
 353      
 354             format = *formatp;
 355      
 356             /* get abstract name first */ 
 357             p = format;
 358             while (*p != '\0' && *p != ' ' &&
 359                    *p != '{' && *p != '}') p++;
 360             if (*p == '\0' || p == format)
 361                     return NULL; /* error */ 
 362      
 363             len = (int) (p-format);
 364             abstract = g_strndup(format, len);
 365      
 366             /* skip the following space, if there's any more spaces they're 
 367                treated as arguments */ 
 368             if (*p == ' ') {
 369                     len++;
 370                     if ((flags & EXPAND_FLAG_IGNORE_EMPTY) && data_is_empty(&p)) {
 371                             *formatp = p;
 372                             g_free(abstract);
 373                             return NULL;
 374                     }
 375             }
 376             *formatp = format+len;
 377      
 378             /* get the abstract data */ 
theme <= 4095379             data = g_hash_table_lookup(theme->abstracts, abstract);     /* Null Pointer Dereference */
       Exit XS_Irssi__UI__Theme_format_expand / theme_format_expand_data / theme_format_expand_abstract
 487                   if (abstract != NULL) {
 488                           g_string_append(str, abstract);
 489                           g_free(abstract);
     Exit XS_Irssi__UI__Theme_format_expand / theme_format_expand_data
Preconditions
&$unknown_1623342 >= 4
&$unknown_1623363 <= &$unknown_1623367 - 1
((char*)$unknown_1623362)[16] != 0
$unknown_1623363 = 123
strlen(&$unknown_1623363) != 0
strlen(&$unknown_1623363) != 1
((char*)&$unknown_1623363)[1] != 0
((char*)&$unknown_1623363)[1] != 123
((char*)&$unknown_1623363)[1] != 125
((char*)&$unknown_1623363)[1] != 32
$unknown_1623367 != 0
$unknown_1623367 != 123
$unknown_1623367 != 125
$unknown_1623367 != 32
strlen(&$unknown_1623367) != 0
strlen(&$unknown_1623367) != 1
((char*)&$unknown_1623367)[1] = 123
Postconditions
_svi' = &$unknown_1623355
_svi' = &$unknown_1623362
$unknown_1623337' = $unknown_1623337 - 4
default_bg' = 110
default_fg' = 110
flags' = ((char*)$unknown_1623362)[16]
format' = &format
format' = &$unknown_1623363 + 1
formatp' = &format
items' = &$unknown_1623342
last_bg' = default_bg'
last_fg' = default_fg'
len' = &$unknown_1623368
p' = &$unknown_1623367 + 1
theme' = 0
theme' = 0
theme' = 0




Change Warning 22022.28489 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: