[GRASS-SVN] r64411 - grass/trunk/display/d.mon
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Feb 3 02:36:36 PST 2015
Author: martinl
Date: 2015-02-03 02:36:36 -0800 (Tue, 03 Feb 2015)
New Revision: 64411
Modified:
grass/trunk/display/d.mon/list.c
Log:
d.mon: fix segfault when no MONITOR dir exists
Modified: grass/trunk/display/d.mon/list.c
===================================================================
--- grass/trunk/display/d.mon/list.c 2015-02-03 10:26:58 UTC (rev 64410)
+++ grass/trunk/display/d.mon/list.c 2015-02-03 10:36:36 UTC (rev 64411)
@@ -37,11 +37,16 @@
struct dirent *dp;
DIR *dirp;
+ *list = NULL;
+ *n = 0;
+
mon_path = get_path(NULL, TRUE);
dirp = opendir(mon_path);
-
- *list = NULL;
- *n = 0;
+ G_free(mon_path);
+
+ if (!dirp)
+ return;
+
while ((dp = readdir(dirp)) != NULL) {
*list = G_realloc(*list, (*n + 1) * sizeof(char *));
if (!dp->d_name || dp->d_name[0] == '.')
@@ -50,8 +55,6 @@
(*n)++;
}
closedir(dirp);
-
- G_free(mon_path);
}
/* print list of running monitors */
More information about the grass-commit
mailing list