diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2019-10-30 14:11:05 +0200 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2019-10-30 14:11:27 +0200 |
commit | 87ef72e1260fee0882a0dcdb8d329b268f09ca0c (patch) | |
tree | a0ec820c6ce959530c7cf88bd72b3013e69a883f /brainfuck.c | |
parent | f36154c03aab2c81c6132a1a411fa0aa30ea4e2a (diff) | |
download | brainfuck-87ef72e1260fee0882a0dcdb8d329b268f09ca0c.tar.gz |
Use memcpy instead of strncpy
Fix warning:
‘strncpy’ output truncated before terminating nul
copying 3 bytes from a string of the same length [-Werror=stringop-truncation]
Diffstat (limited to 'brainfuck.c')
-rw-r--r-- | brainfuck.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/brainfuck.c b/brainfuck.c index 69dae83..fb15282 100644 --- a/brainfuck.c +++ b/brainfuck.c @@ -418,17 +418,17 @@ optimize_code () } /* - * FIXME valid while we use finite integers + * FIXME valid while we use finite integers */ substr = new_code; while (NULL != (substr = strstr (substr, "[-]"))) { - strncpy (substr, "Z ", 3); /* [-] set current cell to 0 */ + memcpy (substr, "Z ", 3); /* [-] set current cell to 0 */ } substr = new_code; while (NULL != (substr = strstr (substr, "[+]"))) { - strncpy (substr, "Z ", 3); /* [-] set current cell to 0 */ + memcpy (substr, "Z ", 3); /* [-] set current cell to 0 */ } free (code); |