mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
lib: fix ownership leaks in FUSE cache insert functions on malloc failure (#321)
In rlc_insert and xac_insert (lib/fuse.c), both functions take ownership of a parameter (link and xattrs respectively) but fail to free it when their own malloc calls fail. Under memory pressure in a long-running FUSE process, each failed cache insertion leaks the owned resource. Co-authored-by: Claude <nore@anthro.com>
This commit is contained in:
@@ -1385,6 +1385,7 @@ xac_insert (guestfs_h *g,
|
|||||||
entry = malloc (sizeof *entry);
|
entry = malloc (sizeof *entry);
|
||||||
if (entry == NULL) {
|
if (entry == NULL) {
|
||||||
perrorf (g, "malloc");
|
perrorf (g, "malloc");
|
||||||
|
guestfs_free_xattr_list (xattrs);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1393,6 +1394,7 @@ xac_insert (guestfs_h *g,
|
|||||||
if (entry->c.pathname == NULL) {
|
if (entry->c.pathname == NULL) {
|
||||||
perrorf (g, "malloc");
|
perrorf (g, "malloc");
|
||||||
free (entry);
|
free (entry);
|
||||||
|
guestfs_free_xattr_list (xattrs);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (STREQ (path, "/"))
|
if (STREQ (path, "/"))
|
||||||
@@ -1418,6 +1420,7 @@ rlc_insert (guestfs_h *g,
|
|||||||
entry = malloc (sizeof *entry);
|
entry = malloc (sizeof *entry);
|
||||||
if (entry == NULL) {
|
if (entry == NULL) {
|
||||||
perrorf (g, "malloc");
|
perrorf (g, "malloc");
|
||||||
|
free (link);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1426,6 +1429,7 @@ rlc_insert (guestfs_h *g,
|
|||||||
if (entry->c.pathname == NULL) {
|
if (entry->c.pathname == NULL) {
|
||||||
perrorf (g, "malloc");
|
perrorf (g, "malloc");
|
||||||
free (entry);
|
free (entry);
|
||||||
|
free (link);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (STREQ (path, "/"))
|
if (STREQ (path, "/"))
|
||||||
|
|||||||
Reference in New Issue
Block a user