mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
LibC: Fix potential double free in ttyname_r_for_directory
If we break out of the loop before we attempt to allocate again, then we double free the memory pointed to by `name_path`. Found by Static Analysis: Sonar Cloud
This commit is contained in:
parent
4674577d80
commit
ecc0459f76
Notes:
sideshowbarker
2024-07-18 00:34:07 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/ecc0459f76 Pull-request: https://github.com/SerenityOS/serenity/pull/13307
|
@ -438,6 +438,7 @@ static int ttyname_r_for_directory(const char* directory_name, dev_t device_mode
|
|||
struct stat st;
|
||||
if (lstat(name_path, &st) < 0) {
|
||||
free(name_path);
|
||||
name_path = nullptr;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue