Module Name: src
Committed By: roy
Date: Sat Jun 2 19:10:33 UTC 2012
Modified Files:
src/lib/libterminfo: tparm.c
Log Message:
Ensure that we request a buffer big enough, although with the current
terminfo specification this should never happen.
Correctly return NULL when realloc(3) fails.
To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libterminfo/tparm.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libterminfo/tparm.c
diff -u src/lib/libterminfo/tparm.c:1.7 src/lib/libterminfo/tparm.c:1.8
--- src/lib/libterminfo/tparm.c:1.7 Mon Oct 3 20:13:48 2011
+++ src/lib/libterminfo/tparm.c Sat Jun 2 19:10:33 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: tparm.c,v 1.7 2011/10/03 20:13:48 roy Exp $ */
+/* $NetBSD: tparm.c,v 1.8 2012/06/02 19:10:33 roy Exp $ */
/*
* Copyright (c) 2009, 2011 The NetBSD Foundation, Inc.
@@ -28,7 +28,8 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: tparm.c,v 1.7 2011/10/03 20:13:48 roy Exp $");
+__RCSID("$NetBSD: tparm.c,v 1.8 2012/06/02 19:10:33 roy Exp $");
+#include <sys/param.h>
#include <assert.h>
#include <ctype.h>
@@ -91,10 +92,10 @@ checkbuf(TERMINAL *term, size_t len)
char *buf;
if (term->_bufpos + len >= term->_buflen) {
- len = term->_buflen + BUFSIZ;
+ len = term->_buflen + MAX(len, BUFSIZ);
buf = realloc(term->_buf, len);
if (buf == NULL)
- return 0;
+ return NULL;
term->_buf = buf;
term->_buflen = len;
}