core: drop unnecessary initialization

cunescape() sets output on success, so initialization is not necessary. There
was no comment, but I think they may have been added because the compiler
wasn't convinced that the return value is non-negative on success. It could
have been confused by the int return type on escape*(), which was changed by
the one of preceeding commits to ssize_t, or by the length calculation, so add
an assert to help the compiler.

For some reason coverity thinks the output can be leaked here (CID #1458111).
I don't see how.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2021-07-09 15:12:18 +02:00
parent 2744c7bb01
commit 1421705d9a
2 changed files with 2 additions and 1 deletions
+1
View File
@@ -355,6 +355,7 @@ ssize_t cunescape_length_with_prefix(const char *s, size_t length, const char *p
*t = 0;
assert(t >= ans); /* Let static analyzers know that the answer is non-negative. */
*ret = TAKE_PTR(ans);
return t - *ret;
}