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 2019-03-10 00:09:38 +01:00
parent 0373696662
commit 554011f828

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);