mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:37:35 +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
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;
|
||||
if (lstat(name_path, &st) < 0) {
|
||||
free(name_path);
|
||||
name_path = nullptr;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue