Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libform allocate the potential trailing nul as well.



details:   https://anonhg.NetBSD.org/src/rev/2425c6a4dcc9
branches:  trunk
changeset: 961221:2425c6a4dcc9
user:      mrg <mrg%NetBSD.org@localhost>
date:      Tue Apr 13 00:29:42 2021 +0000

description:
allocate the potential trailing nul as well.

diffstat:

 lib/libform/type_alnum.c |  4 ++--
 lib/libform/type_alpha.c |  6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diffs (45 lines):

diff -r 2e8d6b28480c -r 2425c6a4dcc9 lib/libform/type_alnum.c
--- a/lib/libform/type_alnum.c  Tue Apr 13 00:29:22 2021 +0000
+++ b/lib/libform/type_alnum.c  Tue Apr 13 00:29:42 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: type_alnum.c,v 1.10 2004/11/24 11:57:09 blymn Exp $    */
+/*     $NetBSD: type_alnum.c,v 1.11 2021/04/13 00:29:42 mrg Exp $      */
 
 /*-
  * Copyright (c) 1998-1999 Brett Lymn
@@ -133,7 +133,7 @@
        if (buf[cur] != '\0')
                return FALSE;
 
-       if ((new = (char *) malloc(sizeof(char) * (end - start))) == NULL)
+       if ((new = (char *) malloc(sizeof(char) * (end - start + 1))) == NULL)
                return FALSE;
 
        if ((end - start) >= 1) {
diff -r 2e8d6b28480c -r 2425c6a4dcc9 lib/libform/type_alpha.c
--- a/lib/libform/type_alpha.c  Tue Apr 13 00:29:22 2021 +0000
+++ b/lib/libform/type_alpha.c  Tue Apr 13 00:29:42 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: type_alpha.c,v 1.11 2004/11/24 11:57:09 blymn Exp $    */
+/*     $NetBSD: type_alpha.c,v 1.12 2021/04/13 00:29:42 mrg Exp $      */
 
 /*-
  * Copyright (c) 1998-1999 Brett Lymn
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: type_alpha.c,v 1.11 2004/11/24 11:57:09 blymn Exp $");
+__RCSID("$NetBSD: type_alpha.c,v 1.12 2021/04/13 00:29:42 mrg Exp $");
 
 #include <stdlib.h>
 #include <string.h>
@@ -136,7 +136,7 @@
                return FALSE;
 
          /* set buffer 0 to the new string */
-       if ((new = (char *) malloc(sizeof(char) * (end - start))) == NULL)
+       if ((new = (char *) malloc(sizeof(char) * (end - start + 1))) == NULL)
                return FALSE;
 
        if ((end - start) >= 1) {



Home | Main Index | Thread Index | Old Index