Skip to content

Commit c4a8037

Browse files
compnerdQuietMisdreavus
authored andcommitted
Silence a warning on Windows (NFCI)
Microsoft considers `strcpy` deprecated preferring `strcpy_s` (see C11 Annex K). Conditionalize the use to Windows, avoiding a warning when building.
1 parent 792c1c3 commit c4a8037

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/syntax_extension.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ void cmark_syntax_extension_free(cmark_mem *mem, cmark_syntax_extension *extensi
2121

2222
cmark_syntax_extension *cmark_syntax_extension_new(const char *name) {
2323
cmark_syntax_extension *res = (cmark_syntax_extension *) _mem->calloc(1, sizeof(cmark_syntax_extension));
24-
res->name = (char *) _mem->calloc(1, sizeof(char) * (strlen(name)) + 1);
24+
size_t size = strlen(name) + 1;
25+
res->name = (char *) _mem->calloc(size, sizeof(char));
26+
#if defined(_WIN32)
27+
strcpy_s(res->name, size, name);
28+
#else
2529
strcpy(res->name, name);
30+
#endif
2631
return res;
2732
}
2833

0 commit comments

Comments
 (0)