summaryrefslogtreecommitdiff
path: root/cord
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2018-11-12 11:12:09 +0300
committerIvan Maidanski <ivmai@mail.ru>2018-11-12 20:45:19 +0300
commit06bd53fff8c91391e4adeeb78640eae00b7bbe09 (patch)
treea7f06967f2cf446f4d731b8abddf9deeb2151e28 /cord
parent5260eb0d79231a2a0800a38a037d361d3502ab48 (diff)
downloadbdwgc-06bd53fff8c91391e4adeeb78640eae00b7bbe09.tar.gz
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.
Diffstat (limited to 'cord')
-rw-r--r--cord/cordbscs.c8
1 files changed, 7 insertions, 1 deletions
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);