mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-14 10:59:24 +02:00
LibC: strdup() forgot to allocate space for the null character.
This commit is contained in:
Notes:
sideshowbarker
2024-07-19 15:52:58 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/ab56f36bfbc
@@ -55,7 +55,7 @@ size_t strlen(const char* str)
|
||||
char* strdup(const char* str)
|
||||
{
|
||||
size_t len = strlen(str);
|
||||
char* new_str = (char*)malloc(len);
|
||||
char* new_str = (char*)malloc(len + 1);
|
||||
strcpy(new_str, str);
|
||||
return new_str;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user