Text  |   XML   |   Visible Warnings:

Irssi : Irssi analysis 1 : Null Pointer Dereference  at themes.c:236

Categories: LANG.MEM.NPD CWE:476
Warning ID: 2327.2337
Procedure: theme_format_append_next
Trace: View
Modified: Wed Sep 2 12:13:33 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
   /u1/paul/SATE/2010/c/irssi/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 <= 3547431                                                NULL, NULL, EXPAND_FLAG_ROOT | flags);
     /u1/paul/SATE/2010/c/irssi/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,
$param_1 <= 3547438                                  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,
theme <= 3547475                                                    recurse_flags);
       Enter XS_Irssi__UI__Theme_format_expand / theme_format_expand_data / theme_format_append_next
 172     static void theme_format_append_next(THEME_REC *theme, GString *str,
 173                                          const char **format,
 174                                          char default_fg, char default_bg,
 175                                          char *last_fg, char *last_bg,
$param_1 <= 3547176                                          int flags) 
 177     {
 178             int index;
 179             unsigned char chr;
 180      
 181             chr = **format;
 182             if ((chr == '$' || chr == '%') &&
 183                 (*format)[1] == '\0') {
 184                     /* last char, always append */ 
 185                     g_string_append_c(str, chr);
 186                     (*format)++;
 187                     return;
 188             }
 189      
 190             if (chr == '$') {
 191                     /* $variable .. we'll always need to skip this, since it 
 192                        may contain characters that are in replace chars. */ 
 193                     theme_format_append_variable(str, format);
 194                     return;
 195             }
 196      
 197             if (**format == '%') {
 198                     /* format */ 
 199                     (*format)++;
theme <= 3547200                     if (**format != '{' && **format != '}') {
 201                             chr = **format;
 202                             if (**format == 'n') {
 203                                     /* %n = change to default color */ 
 204                                     g_string_append(str, "%n");
 205      
 206                                     if (default_bg != 'n') {
 207                                             g_string_append_c(str, '%');
 208                                             g_string_append_c(str, default_bg);
 209                                     }
 210                                     if (default_fg != 'n') {
       ...
 221                                             *last_bg = chr;
 222                                     g_string_append_c(str, '%');
 223                                     g_string_append_c(str, chr);
 224                             }
 225                             (*format)++;
 226                             return;
 227                     }
 228      
 229                     /* %{ or %} gives us { or } char - keep the % char 
 230                        though to make sure {} isn't treated as abstract */ 
 231                     g_string_append_c(str, '%');
 232                     chr = **format;
 233             }
 234      
 235             index = (flags & EXPAND_FLAG_IGNORE_REPLACES) ? -1 : 
 236                     theme->replace_keys[(int) (unsigned char) chr];     /* Null Pointer Dereference */
       Exit XS_Irssi__UI__Theme_format_expand / theme_format_expand_data / theme_format_append_next
     Exit XS_Irssi__UI__Theme_format_expand / theme_format_expand_data
Preconditions
&$unknown_2549565 >= 4
&$unknown_2549601 = 37
((char*)$unknown_2549593)[24] != 0
$unknown_2549599 = 37
strlen(&$unknown_2549599) != 0
strlen(&$unknown_2549599) != 1
((char*)&$unknown_2549599)[1] = 125
((char*)&$unknown_2549600)[8] <= ((char*)&$unknown_2549600)[16] - 2
Postconditions
strlen($unknown_2549600)' = ((char*)&$unknown_2549600)[8] + 1
_svi' = &$unknown_2549582
_svi' = &$unknown_2549593
$unknown_2549559' = $unknown_2549559 - 4
((char*)&$unknown_2549600)[8]' = ((char*)&$unknown_2549600)[8] + 1
chr' = ((char*)&$unknown_2549599)[1]
cv' = $param_2
default_bg' = 110
default_bg' = 110
default_fg' = 110
default_fg' = 110
flags' = ((char*)$unknown_2549593)[24]
format' = &format
format' = &$unknown_2549599 + 1
format' = &format
items' = &$unknown_2549565
last_bg' = &last_bg
last_bg' = 110
last_fg' = 110
last_fg' = &last_fg
my_perl' = $param_1
recurse_flags' = flags'
save_last_bg' = 0
save_last_fg' = 0
str' = &$unknown_2549600
str' = &$unknown_2549600
theme' = 0
theme' = 0
theme' = 0




Change Warning 2327.2337 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: