From 10a9c5194222c3ebdb740a366056092f0e3a62d5 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Wed, 13 Jun 2018 12:27:57 +0200 Subject: [PATCH] emalloc never returns null --- ext/xmlrpc/libxmlrpc/encodings.c | 34 +++++++++++++++----------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/ext/xmlrpc/libxmlrpc/encodings.c b/ext/xmlrpc/libxmlrpc/encodings.c index 5777152ea8..a2e6ff194b 100644 --- a/ext/xmlrpc/libxmlrpc/encodings.c +++ b/ext/xmlrpc/libxmlrpc/encodings.c @@ -67,26 +67,24 @@ static char* convert(const char* src, int src_len, int *new_len, const char* fro size_t st; outbuf = (char*)emalloc(outlen + 1); - if(outbuf) { - out_ptr = (char*)outbuf; - while(inlenleft) { - st = iconv(ic, (char**)&src, &inlenleft, &out_ptr, &outlenleft); - if(st == -1) { - if(errno == E2BIG) { - int diff = out_ptr - outbuf; - outlen += inlenleft; - outlenleft += inlenleft; - outbuf = (char*)erealloc(outbuf, outlen + 1); - if(!outbuf) { - break; - } - out_ptr = outbuf + diff; - } - else { - efree(outbuf); - outbuf = 0; + out_ptr = (char*)outbuf; + while(inlenleft) { + st = iconv(ic, (char**)&src, &inlenleft, &out_ptr, &outlenleft); + if(st == -1) { + if(errno == E2BIG) { + int diff = out_ptr - outbuf; + outlen += inlenleft; + outlenleft += inlenleft; + outbuf = (char*)erealloc(outbuf, outlen + 1); + if(!outbuf) { break; } + out_ptr = outbuf + diff; + } + else { + efree(outbuf); + outbuf = 0; + break; } } } -- 2.40.0