From c18f5e1edddf68bd449cb2b8e55d47a7da622cde Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sat, 25 Jul 2015 20:05:58 +0200 Subject: [PATCH] add NULL check --- sapi/phpdbg/phpdbg_list.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sapi/phpdbg/phpdbg_list.c b/sapi/phpdbg/phpdbg_list.c index e577333837..3d64c8b077 100644 --- a/sapi/phpdbg/phpdbg_list.c +++ b/sapi/phpdbg/phpdbg_list.c @@ -244,9 +244,12 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type) { return NULL; } - data.buf = emalloc(data.len + 1); - memcpy(data.buf, bufptr, data.len); - data.buf[data.len] = 0; + data.buf = NULL; + if (data.len > 0) { + data.buf = emalloc(data.len + 1); + memcpy(data.buf, bufptr, data.len); + data.buf[data.len] = 0; + } data.filename = filename; data.line[0] = 0; -- 2.40.0