Fix ASAN crash bug: allocate extra byte for null terminator in dbuf_str
This commit is contained in:
parent
b2891d0cff
commit
2f9dfb38ca
1 changed files with 2 additions and 2 deletions
4
cutils.h
4
cutils.h
|
|
@ -792,9 +792,9 @@ static inline const char *dbuf_str(DynBuf *s) {
|
|||
@note: a null terminator is set at the end of the buffer and an empty
|
||||
string is returned if the buffer has not been allocated.
|
||||
*/
|
||||
if (s->size == 0)
|
||||
if (s->size == 0 || dbuf_putc(s, '\0'))
|
||||
return "";
|
||||
s->buf[s->size] = '\0';
|
||||
s->size--;
|
||||
return cs8(s->buf);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue