Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/sushi form_appenditem(): make sure fte->list is ini...
details: https://anonhg.NetBSD.org/src/rev/a65bdc556669
branches: trunk
changeset: 534416:a65bdc556669
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Thu Jul 25 12:42:39 2002 +0000
description:
form_appenditem(): make sure fte->list is initialized
process_{pre,}form(): g/c unnecessary malloc, plug memory leak
gen_list(): only check ftp->list after realloc()
handle_{pre,}form(): allocate F[] via calloc(3), so that the memory is
properly zeroed
diffstat:
usr.sbin/sushi/scanform.c | 17 ++++++++---------
1 files changed, 8 insertions(+), 9 deletions(-)
diffs (67 lines):
diff -r cc7ccf69f2c7 -r a65bdc556669 usr.sbin/sushi/scanform.c
--- a/usr.sbin/sushi/scanform.c Thu Jul 25 12:41:51 2002 +0000
+++ b/usr.sbin/sushi/scanform.c Thu Jul 25 12:42:39 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: scanform.c,v 1.22 2002/07/25 09:38:31 jdolecek Exp $ */
+/* $NetBSD: scanform.c,v 1.23 2002/07/25 12:42:39 jdolecek Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -141,6 +141,7 @@
fte->required = req;
fte->elen = 0;
fte->origdata = fte->data;
+ fte->list = NULL;
CIRCLEQ_INIT(&fte->cqSubFormHead);
CIRCLEQ_INSERT_TAIL(cqf, fte, cqFormEntries);
@@ -792,8 +793,7 @@
bailout("malloc: %s", strerror(errno));
fc = lcnt = field_count(form);
args = realloc(args, sizeof(char *) * (lcnt+1));
- f = malloc(sizeof(FIELD *) * lcnt);
- if (f == NULL || args == NULL)
+ if (args == NULL)
bailout("malloc: %s", strerror(errno));
f = form_fields(form);
@@ -896,8 +896,7 @@
fc = lcnt = field_count(form);
args = realloc(args, sizeof(char *) * (lcnt+1+i));
- f = malloc(sizeof(FIELD *) * lcnt);
- if (f == NULL || args == NULL)
+ if (args == NULL)
bailout("malloc: %s", strerror(errno));
f = form_fields(form);
@@ -1044,9 +1043,9 @@
if (i == lmax - 2) {
lmax += 10;
ftp->list = realloc(ftp->list, sizeof(char*) * lmax);
+ if (ftp->list == NULL)
+ bailout("realloc: %s", strerror(errno));
}
- if (ftp->list == NULL)
- bailout("realloc: %s", strerror(errno));
}
ftp->list[i] = NULL;
}
@@ -1590,7 +1589,7 @@
if (scan_form(cqFormHeadp, path))
return(1);
- F = malloc(sizeof(FIELD_RECORD) *
+ F = calloc(sizeof(FIELD_RECORD),
(form_entries(&cqFormHead) * 2 + 1));
if (F == NULL)
bailout("malloc: %s", strerror(errno));
@@ -1691,7 +1690,7 @@
if (scan_form(cqFormHeadp, path))
return(1);
- F = malloc(sizeof(FIELD_RECORD) *
+ F = calloc(sizeof(FIELD_RECORD),
(form_entries(&cqFormHead) * 2 + 1));
if (F == NULL)
bailout("malloc: %s", strerror(errno));
Home |
Main Index |
Thread Index |
Old Index