Author: TomaszN <nowak2000@poczta.onet.pl>	vim:ft=diff:
Description: fix memory leak issue, BTS #590942

Index: b/curses.c
===================================================================
--- a/curses.c
+++ b/curses.c
@@ -141,6 +141,8 @@ ExtFunc void GetTermcapInfo(void)
 		 * Allocate it on the heap too.
 		 */
 		data = buf = malloc(bufSize);
+		if (buf == NULL)
+			fatal("memory allocation error");
 
 		/*
 		 * There is no standard include file for tgetstr, no prototype
@@ -154,9 +156,6 @@ ExtFunc void GetTermcapInfo(void)
 		/* Okay, so I'm paranoid; I just don't like unsafe routines */
 		if (data > buf + bufSize)
 			fatal("tgetstr overflow, you must have a very sick termcap");
-
-		/* Trim off the unused portion of buffer */
-		buf = realloc(buf, data - buf);
 	}
 
 	/*
