aboutsummaryrefslogtreecommitdiff
path: root/description
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2021-06-28 08:39:32 -0300
committerEuAndreh <eu@euandre.org>2021-06-28 09:48:01 -0300
commit17a6c7bda9ec97c03153ebfabf3a99c9f66dc7f5 (patch)
tree398ee27665ffde668fef461b21f5d2f64883659c /description
parentsrc/remembering-c.c: Use better grouping of parentheses for strcmp() (diff)
downloadremembering-17a6c7bda9ec97c03153ebfabf3a99c9f66dc7f5.tar.gz
remembering-17a6c7bda9ec97c03153ebfabf3a99c9f66dc7f5.tar.xz
src/remembering-c.c: Fix usage of strcat()
As it turns out, after doing a malloc(), strcat() can't be used directly on top of it. I'd guess that the implementation of strcat() goes through the first string until its end, the \0 NULL terminator, and then starts copying the characters to the new string, overwriting the existing terminator to allow the string to actually be continuous. However, strcat() can't do this in a string that was just malloced and has no content. So it will probably run over the end of the memory untill it finds a NULL byte, and concatenate starting from that. I didn't check this elsewhere, but this explanation sounds reasonable, and Valgrind's diagnostics seem to confirm that. The solution is to strcpy() the first string, and than strcat() the others after that, so that strcat() has an existing string to work on, while strcpy doesn't need that. Fixes #task-bd165b74-c559-48ee-1d29-eaa906aa0393.
Diffstat (limited to 'description')
0 files changed, 0 insertions, 0 deletions