Commit 278d97f7 by Serge Hallyn

coverity: ovl_clonepaths: free osrc and ndelta on error paths

parent 7d72b959
...@@ -177,18 +177,26 @@ int ovl_clonepaths(struct bdev *orig, struct bdev *new, const char *oldname, ...@@ -177,18 +177,26 @@ int ovl_clonepaths(struct bdev *orig, struct bdev *new, const char *oldname,
* up) * up)
*/ */
lastslash = strrchr(ndelta, '/'); lastslash = strrchr(ndelta, '/');
if (!lastslash) if (!lastslash) {
free(osrc);
free(ndelta);
return -1; return -1;
}
lastslash++; lastslash++;
lastslashidx = lastslash - ndelta; lastslashidx = lastslash - ndelta;
work = malloc(lastslashidx + 7); work = malloc(lastslashidx + 7);
if (!work) if (!work) {
free(osrc);
free(ndelta);
return -1; return -1;
}
strncpy(work, ndelta, lastslashidx + 1); strncpy(work, ndelta, lastslashidx + 1);
strcpy(work + lastslashidx, "olwork"); strcpy(work + lastslashidx, "olwork");
if ((mkdir(work, 0755) < 0) && errno != EEXIST) { if ((mkdir(work, 0755) < 0) && errno != EEXIST) {
SYSERROR("error: mkdir %s", work); SYSERROR("error: mkdir %s", work);
free(osrc);
free(ndelta);
free(work); free(work);
return -1; return -1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment