Skip to content

Commit 886b643

Browse files
committed
iio_common: fix an off by one that was introduced during 9a00766
found this while debugging trigger issues. Signed-off-by: Robin Getz <[email protected]>
1 parent 3f69133 commit 886b643

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

tests/iio_common.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,10 @@ char *cmn_strndup(const char *str, size_t n)
5656
#else
5757
size_t len = strnlen(str, n + 1);
5858
char *buf = malloc(len + 1);
59-
6059
if (buf) {
6160
/* len = size of buf, so memcpy is OK */
6261
memcpy(buf, str, len); /* Flawfinder: ignore */
63-
buf[len + 1] = 0;
62+
buf[len] = 0;
6463
}
6564
return buf;
6665
#endif

0 commit comments

Comments
 (0)