Skip to content

Commit b313ae7

Browse files
committed
Mod
1 parent 9eeb76c commit b313ae7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

c/src/safec.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
char * strdup_s(const char * restrict str, size_t len)
88
{
9+
if (str == NULL)
10+
{
11+
return NULL;
12+
}
913
len = strnlen_s(str, len) + 1;
1014
char * mem = malloc(sizeof(char) * len);
1115
if (mem == NULL)
@@ -18,6 +22,10 @@ char * strdup_s(const char * restrict str, size_t len)
1822
}
1923
wchar_t * wcsdup_s(const wchar_t * restrict wstr, size_t len)
2024
{
25+
if (wstr == NULL)
26+
{
27+
return NULL;
28+
}
2129
len = wcsnlen_s(wstr, len) + 1;
2230
wchar_t * mem = malloc(sizeof(wchar_t) * len);
2331
if (mem == NULL)

0 commit comments

Comments
 (0)