userlandfs/server/fuse: Fix potential memory leak
* Fix potential leak of 'cookie' at line 2206, which is allocated at line 2203. Pointed out by Clang Static Analyzer. * Add NULL check to 'cookie'. Change-Id: Ibfdbe3a52ceb0d29adf1acca51fb7b27d2c532f3 Reviewed-on: https://review.haiku-os.org/c/1065 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
parent
b7223dc11f
commit
d938c7118f
@ -2201,9 +2201,13 @@ FUSEVolume::OpenAttr(void* _node, const char* name, int openMode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
AttrCookie* cookie = new(std::nothrow)AttrCookie(name);
|
AttrCookie* cookie = new(std::nothrow)AttrCookie(name);
|
||||||
|
if (cookie == NULL)
|
||||||
|
RETURN_ERROR(B_NO_MEMORY);
|
||||||
error = cookie->Allocate(attrSize);
|
error = cookie->Allocate(attrSize);
|
||||||
if (error != B_OK)
|
if (error != B_OK) {
|
||||||
|
delete cookie;
|
||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
|
}
|
||||||
|
|
||||||
int bytesRead = fuse_fs_getxattr(fFS, path, name, cookie->Buffer(),
|
int bytesRead = fuse_fs_getxattr(fFS, path, name, cookie->Buffer(),
|
||||||
attrSize);
|
attrSize);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user