Ensure that ensure_space() does not leave a NULL pointer

This commit is contained in:
Kovid Goyal 2019-06-24 16:00:45 +05:30
parent 9c9eac9d46
commit af3504e05c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -25,7 +25,7 @@ static inline ssize_t ms_write(int fd, const void* buf, size_t count) { return _
static inline bool
ensure_space(GlobalData *global, size_t sz) {
if (global->output_sz < sz + global->output_pos) {
if (global->output_sz < sz + global->output_pos || !global->output) {
size_t before = global->output_sz;
global->output_sz += MAX(sz, (64 * 1024));
global->output = realloc(global->output, sizeof(text_t) * global->output_sz);