Skip to content

Commit ce783c2

Browse files
author
Nikolaas N. Oosterhof
committed
ENH: avoid false-positive warning for snprintf
1 parent f33f2e6 commit ce783c2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

MOcov/mocov_line_covered.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,9 @@ void raise_mex_error(const char *error_id_label, const char *error_message) {
189189
}
190190

191191
// Concatenate the prefix and the original error_id into new_errorid
192-
snprintf(error_id, MAX_ERROR_ID_LENGTH, "%s%s", ERROR_ID_PREFIX,
193-
error_id_label);
192+
size_t prefix_len = strlen(ERROR_ID_PREFIX);
193+
snprintf(error_id, MAX_ERROR_ID_LENGTH, "%s", ERROR_ID_PREFIX);
194+
strncat(error_id, error_id_label, MAX_ERROR_ID_LENGTH - prefix_len - 1);
194195

195196
// Call the original mexErrMsgIdAndTxt function with the new error_id
196197
mexErrMsgIdAndTxt(error_id, error_message);

0 commit comments

Comments
 (0)