summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fd168f7)
raw | patch | inline | side by side (parent: fd168f7)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Wed, 23 Nov 2011 08:52:37 +0000 (08:52 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Wed, 23 Nov 2011 08:52:37 +0000 (08:52 +0000) |
src/rrd_utils.c | patch | blob | history |
diff --git a/src/rrd_utils.c b/src/rrd_utils.c
index 3c4930f93d285d0a500f0d6b8524259ac575a864..add19c31af61027762f10aa3e658e9e5419a2066 100644 (file)
--- a/src/rrd_utils.c
+++ b/src/rrd_utils.c
return -1;
#ifndef _MSC_VER
- base_dir = dirname(pathname_copy);
+ /* the data pointedd too by dirname might change too (bsd) */
+ if (NULL == (base_dir = strdup(dirname(pathname_copy)))) {
+ free(pathname_copy);
+ return -1;
+ }
#else
- _splitpath(pathname_copy, NULL, base_dir, NULL, NULL);
+ _splitpath(pathname_copy, NULL, base_dir, NULL, NULL);
#endif
if (0 != rrd_mkdir_p(base_dir, mode)) {
int orig_errno = errno;
free(pathname_copy);
+#ifndef _MSC_VER
+ free(base_dir);
+#endif
errno = orig_errno;
return -1;
}
free(pathname_copy);
+#ifndef _MSC_VER
+ free(base_dir);
+#endif
/* keep errno as set by mkdir() */
#ifdef _MSC_VER
- if (0 != mkdir(pathname))
+ if (0 != mkdir(pathname))
return -1;
#else
if (0 != mkdir(pathname, mode))