1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 22:17:42 +00:00

LibC: strdup() forgot to allocate space for the null character.

This commit is contained in:
Andreas Kling 2019-02-03 11:48:41 +01:00
parent 9da9cce4f7
commit ab56f36bfb

View file

@ -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;
}