Closed kokke closed 2 years ago
Thanks for the bug report and patch!!! I implemented your proposal a bit differently as I still try to follow the C89 "no statements before declarations" rule (which is probably completely obsolete by now, but still, rlwrap promises to be especially useful on obsolete systems....
See b3c0890affc8732b2238acf93c2b63fd5bb0677b
Hi @hanslub42 - that totally makes sense to me 👍
Thanks for considering my inputs - I hope you have a nice day 😃
This PR fixes a small issue where pointers are checked against NULL but the check happens after the pointer was already dereferenced.
Specifically in src/string_utils.c line 351:
strlen(ptr)
dereferences 'ptr' so if 'patt', 'repl' or 'string' was ever NULL, the program would crash before reaching theassert
-statement.See below lines 342, 343, 344 + 351 for comments explaining the issue.
My suggested solution is to move the
assert
-statement up to the top of the function, before the pointers are used (passed tostrlen()
) - so the code becomes like this: