Text  |   XML   |   Visible Warnings:

irssi-0.8.14 : irssi-0.8.14 analysis 2 : Null Test After Dereference  at completion.c:319

Categories: LANG.STRUCT.NTAD
Warning ID: 7288.28376
Procedure: filename_complete
Trace: view
Modified: Thu Nov 26 11:09:10 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
  /kat0/fletcher/SATE/2010/irssi-0.8.14/src/fe-common/core/completion.c
  Enter filename_complete
282 GList *filename_complete(const char *path, const char *default_path) 
283 {
284         GList *list;
285         DIR *dirp;
286         struct dirent *dp;
287         const char *basename;
288         char *realpath, *dir, *name;
289         int len;
290  
291         g_return_val_if_fail(path != NULL, NULL);
292  
293         list = NULL;
294  
295         /* get directory part of the path - expand ~/ */ 
296         realpath = convert_home(path);
297         if (USE_DEFAULT_PATH(realpath, default_path)) {
298                 g_free(realpath);
299                 realpath = g_strconcat(default_path, G_DIR_SEPARATOR_S,
300                                        path, NULL);
301         }
302  
303         /* open directory for reading */ 
304         dir = g_path_get_dirname(realpath);
305         dirp = opendir(dir);
306         g_free(dir);
307         g_free(realpath);
308  
309         if (dirp == NULL)
310                 return NULL;
311  
312         dir = g_path_get_dirname(path);
313         if (*dir == G_DIR_SEPARATOR && dir[1] == '\0') {
314                 /* completing file in root directory */ 
315                 *dir = '\0';
316         } else if (IS_CURRENT_DIR(dir) && !IS_CURRENT_DIR(path)) {
317                 /* completing file in default_path 
318                    (path not set, and leave it that way) */ 
319                 g_free_and_null(dir);     /* Null Test After Dereference */
320         }
321  
322         basename = g_basename(path);
323         len = strlen(basename);
324  
325         /* add all files in directory to completion list */ 
326         while ((dp = readdir(dirp)) != NULL) {
327                 if (dp->d_name[0] == '.') {
328                         if (dp->d_name[1] == '\0' ||
329                             (dp->d_name[1] == '.' && dp->d_name[2] == '\0'))
330                                 continue; /* skip . and .. */ 
331  
332                         if (basename[0] != '.')
333                                 continue;
334                 }
335  
336                 if (len == 0 || strncmp(dp->d_name, basename, len) == 0) {
337                         name = dir == NULL ? g_strdup(dp->d_name) : 
338                                 g_strdup_printf("%s"G_DIR_SEPARATOR_S"%s", dir, dp->d_name);
339                         list = list_add_file(list, name, default_path);
340                         g_free(name);
341                 }
342         }
343         closedir(dirp);
344  
345         g_free_not_null(dir);
346         return list;
347 } 




Change Warning 7288.28376 : Null Test After Dereference

Priority:
State:
Finding:
Owner:
Note: