mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibC: Verify pointer returned by malloc()
This commit is contained in:
parent
bdb8af94ee
commit
72911cd006
Notes:
sideshowbarker
2024-07-17 01:04:03 +09:00
Author: https://github.com/h3xOo Commit: https://github.com/SerenityOS/serenity/commit/72911cd006 Pull-request: https://github.com/SerenityOS/serenity/pull/23785 Reviewed-by: https://github.com/LucasChollet
1 changed files with 3 additions and 0 deletions
|
@ -448,6 +448,9 @@ static int ttyname_r_for_directory(char const* directory_name, dev_t device_mode
|
|||
}
|
||||
|
||||
name_path = (char*)malloc(name_length);
|
||||
// FIXME: ttyname_r() is not allowed to return ENOMEM, find better way to store name_path,
|
||||
// perhaps a static storage.
|
||||
VERIFY(name_path);
|
||||
memset(name_path, 0, name_length);
|
||||
memcpy(name_path, directory_name, strlen(directory_name));
|
||||
memcpy(&name_path[strlen(directory_name)], entry->d_name, strlen(entry->d_name));
|
||||
|
|
Loading…
Reference in a new issue