Fix warning: ‘strncpy’ output truncated before terminating nul copying as many bytes from a string as its length

This commit is contained in:
Philippe Teuwen committed 2019-03-10 00:09:46 +01:00
1 parent 0373696662
commit 554011f828
1 file changed
+1 -1
+1 -1
View File
@@ -24,7 +24,7 @@ void jsonp_error_set_source(json_error_t *error, const char *source)
length = strlen(source);
if (length < JSON_ERROR_SOURCE_LENGTH) {
strncpy(error->source, source, length);
strncpy(error->source, source, JSON_ERROR_SOURCE_LENGTH);
} else {
size_t extra = length - JSON_ERROR_SOURCE_LENGTH + 4;
memcpy(error->source, "...", 3);