mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-12 04:22:28 +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: ecc0459f76
Pull-request: https://github.com/SerenityOS/serenity/pull/13307
1 changed files with 1 additions and 0 deletions
|
@ -438,6 +438,7 @@ static int ttyname_r_for_directory(const char* directory_name, dev_t device_mode
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (lstat(name_path, &st) < 0) {
|
if (lstat(name_path, &st) < 0) {
|
||||||
free(name_path);
|
free(name_path);
|
||||||
|
name_path = nullptr;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue