Skip to content

Commit ab56f36

Browse files
committed
LibC: strdup() forgot to allocate space for the null character.
1 parent 9da9cce commit ab56f36

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

LibC/string.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ size_t strlen(const char* str)
5555
char* strdup(const char* str)
5656
{
5757
size_t len = strlen(str);
58-
char* new_str = (char*)malloc(len);
58+
char* new_str = (char*)malloc(len + 1);
5959
strcpy(new_str, str);
6060
return new_str;
6161
}

0 commit comments

Comments
 (0)