mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-21 02:01:38 +00:00
libc_fs: fix potential memory leak in symlink()
Free always the file descriptor and plugin context, return the appropriate value to the caller and only in the error case set errno. Fixes #1009.
This commit is contained in:
parent
f71e38702f
commit
2e6255d1cf
@ -722,13 +722,16 @@ class Plugin : public Libc::Plugin
|
||||
Libc::File_descriptor *fd =
|
||||
Libc::file_descriptor_allocator()->alloc(this, context);
|
||||
|
||||
if (write(fd, oldpath, strlen(oldpath) + 1) == -1) {
|
||||
ssize_t res = write(fd, oldpath, strlen(oldpath) + 1);
|
||||
|
||||
Libc::file_descriptor_allocator()->free(fd);
|
||||
destroy(Genode::env()->heap(), context);
|
||||
|
||||
if (res == -1) {
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (File_system::Lookup_failed) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user