mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-03-27 07:48:09 +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:
committed by
Brian Gianforcaro
parent
4674577d80
commit
ecc0459f76
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user