From 08f61e60ca47bc7406bf02ae93954fa012a42921 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 1 Sep 2015 11:57:22 +0200 Subject: [PATCH] Fixed zero length allocation. --- libfreerdp/codec/rfx.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libfreerdp/codec/rfx.c b/libfreerdp/codec/rfx.c index c4ba2d3f8..f05c013f6 100644 --- a/libfreerdp/codec/rfx.c +++ b/libfreerdp/codec/rfx.c @@ -1552,12 +1552,20 @@ skip_encoding_loop: if (success && message->numTiles != maxNbTiles) { - void* pmem = realloc((void*) message->tiles, sizeof(RFX_TILE*) * message->numTiles); + if (message->numTiles > 0) + { + void* pmem = realloc((void*) message->tiles, sizeof(RFX_TILE*) * message->numTiles); - if (pmem) - message->tiles = (RFX_TILE**) pmem; + if (pmem) + message->tiles = (RFX_TILE**) pmem; + else + success = FALSE; + } else + { + free(message->tiles); success = FALSE; + } } /* when using threads ensure all computations are done */