Message ID | 20231214202549.580231-1-preichl@redhat.com (mailing list archive) |
---|---|
State | Deferred, archived |
Headers | show |
Series | [v2] xfsdump: Fix memory leak | expand |
diff --git a/restore/tree.c b/restore/tree.c index 6f3180f..4707fdc 100644 --- a/restore/tree.c +++ b/restore/tree.c @@ -4977,9 +4977,22 @@ static int mkdir_r(char *path) { struct stat sbuf; + char *path_copy; + int ret; if (stat(path, &sbuf) < 0) { - if (mkdir_r(dirname(strdup(path))) < 0) + path_copy = strdup(path); + if (!path_copy) { + mlog(MLOG_TRACE | MLOG_ERROR | MLOG_TREE, + _("unable to allocate memory for a path\n")); + mlog_exit(EXIT_ERROR, RV_ERROR); + exit(1); + } + + ret = mkdir_r(dirname(path_copy)); + free(path_copy); + + if (ret < 0) return -1; return mkdir(path, 0755); }