From 0f7148695beddf0a9fd9803547f48d3db1368c86 Mon Sep 17 00:00:00 2001 From: Ander Conselvan de Oliveira Date: Wed, 23 Mar 2011 14:36:22 +0200 Subject: Fix memory leak with broken bitmap files in XReadBitmapFileData Bitmap file data is read looping through the lines in the input file. If there is extra data after the bitmap, these lines will be processed and if this data represents another bitmap it will replace the one read before causing the memory allocated for bits to leak. This changes the code to stop processing the file once a bitmap was read. Signed-off-by: Ander Conselvan de Oliveira Reviewed-by: Alan Coopersmith Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/RdBitF.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nx-X11/lib/X11/RdBitF.c b/nx-X11/lib/X11/RdBitF.c index b3c21bc53..2ec100aa3 100644 --- a/nx-X11/lib/X11/RdBitF.c +++ b/nx-X11/lib/X11/RdBitF.c @@ -216,6 +216,11 @@ XReadBitmapFileData ( *ptr=value; } } + + /* If we got to this point, we read a full bitmap file. Break so we don't + * start reading another one from the same file and leak the memory + * allocated for the previous one. */ + break; } /* end while */ fclose(fstream); -- cgit v1.2.3