[PATCH:libX11 07/22] lcDB.c: ensure buffer size is updated correctly if realloc fails

Alan Coopersmith alan.coopersmith at oracle.com
Mon Aug 12 00:03:58 PDT 2013


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 src/xlibi18n/lcDB.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/xlibi18n/lcDB.c b/src/xlibi18n/lcDB.c
index 97b22ac..5048122 100644
--- a/src/xlibi18n/lcDB.c
+++ b/src/xlibi18n/lcDB.c
@@ -210,11 +210,12 @@ realloc_parse_info(
     int len)
 {
     char *p;
+    int newsize = BUFSIZE * ((parse_info.bufsize + len)/BUFSIZE + 1);
 
-    parse_info.bufMaxSize = BUFSIZE * ((parse_info.bufsize + len)/BUFSIZE + 1);
-    p = (char *)Xrealloc(parse_info.buf, parse_info.bufMaxSize);
+    p = Xrealloc(parse_info.buf, newsize);
     if (p == NULL)
         return False;
+    parse_info.bufMaxSize = newsize;
     parse_info.buf = p;
 
     return True;
-- 
1.7.9.2



More information about the xorg-devel mailing list