From: Ivan Maidanski Date: Mon, 12 Nov 2018 08:12:09 +0000 (+0300) Subject: Workaround 'potential non-terminated string' false positive in cordbscs X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=06bd53fff8c91391e4adeeb78640eae00b7bbe09;p=gc Workaround 'potential non-terminated string' false positive in cordbscs * cordbscs.c [LINT2] (CORD_cat_char_star): Pass lenx+1 to memcpy() instead of lenx; add comment. --- diff --git a/cord/cordbscs.c b/cord/cordbscs.c index ff0d2399..a92ab639 100644 --- a/cord/cordbscs.c +++ b/cord/cordbscs.c @@ -170,7 +170,13 @@ CORD CORD_cat_char_star(CORD x, const char * y, size_t leny) char * result = (char *)GC_MALLOC_ATOMIC(result_len + 1); if (result == 0) OUT_OF_MEMORY; - memcpy(result, x, lenx); +# ifdef LINT2 + memcpy(result, x, lenx + 1); +# else + memcpy(result, x, lenx); + /* No need to copy the terminating zero */ + /* as result[lenx] is written below. */ +# endif memcpy(result + lenx, y, leny); result[result_len] = '\0'; return((CORD) result);