Skip to content
Snippets Groups Projects
Commit c08f1613 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Fix NULL dereference in strbuf error

If strbuf is over 5MB, or the realloc() fails, clear strbuf and
break before writing to strbuf.
Found by scan-build
parent 433e4147
No related branches found
No related tags found
No related merge requests found
......@@ -5615,12 +5615,14 @@ CIOLIBEXPORT char* cterm_write(struct cterminal * cterm, const void *vbuf, int b
if (cterm->strbufsize > 1024 * 1024 * 512) {
FREE_AND_NULL(cterm->strbuf);
cterm->strbuflen = cterm->strbufsize = 0;
break;
}
else {
p = realloc(cterm->strbuf, cterm->strbufsize);
if (p == NULL) {
FREE_AND_NULL(cterm->strbuf);
cterm->strbuflen = cterm->strbufsize = 0;
break;
}
else
cterm->strbuf = p;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment