summaryrefslogtreecommitdiffstats
path: root/lib/libc/nls
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1997-05-10 04:40:40 +0000
committerache <ache@FreeBSD.org>1997-05-10 04:40:40 +0000
commitfecb2556c8edf43dca1bcc0ce180495d6eeb03e3 (patch)
tree199d1d116bf525a3710c86318c9800547dd3581e /lib/libc/nls
parentd4628da6086df0893152fd9af3f131b7a4fdc54c (diff)
downloadFreeBSD-src-fecb2556c8edf43dca1bcc0ce180495d6eeb03e3.zip
FreeBSD-src-fecb2556c8edf43dca1bcc0ce180495d6eeb03e3.tar.gz
Plug even more failure memory leaks
Diffstat (limited to 'lib/libc/nls')
-rw-r--r--lib/libc/nls/msgcat.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/lib/libc/nls/msgcat.c b/lib/libc/nls/msgcat.c
index 17d6111..c90cefb 100644
--- a/lib/libc/nls/msgcat.c
+++ b/lib/libc/nls/msgcat.c
@@ -1,4 +1,4 @@
-/* $Id: msgcat.c,v 1.9 1997/03/25 05:36:37 imp Exp $ */
+/* $Id: msgcat.c,v 1.10 1997/05/10 04:28:17 ache Exp $ */
/***********************************************************
Copyright 1990, by Alfalfa Software Incorporated, Cambridge, Massachusetts.
@@ -293,7 +293,7 @@ int type;
MCHeaderT header;
MCCatT *cat;
MCSetT *set;
- long i;
+ long i, j;
off_t nextSet;
cat = (MCCatT *) malloc(sizeof(MCCatT));
@@ -331,13 +331,31 @@ int type;
nextSet = header.firstSet;
for (i = 0; i < cat->numSets; ++i) {
- if (lseek(cat->fd, nextSet, 0) == -1)
- {free(cat->sets); CORRUPT();}
+ if (lseek(cat->fd, nextSet, 0) == -1) {
+ for (j = 0; j < i; j++) {
+ set = cat->sets + j;
+ if (!set->invalid) {
+ free(set->data.str);
+ free(set->u.msgs);
+ }
+ }
+ free(cat->sets);
+ CORRUPT();
+ }
/* read in the set header */
set = cat->sets + i;
- if (read(cat->fd, set, sizeof(*set)) != sizeof(*set))
- {free(cat->sets); CORRUPT();}
+ if (read(cat->fd, set, sizeof(*set)) != sizeof(*set)) {
+ for (j = 0; j < i; j++) {
+ set = cat->sets + j;
+ if (!set->invalid) {
+ free(set->data.str);
+ free(set->u.msgs);
+ }
+ }
+ free(cat->sets);
+ CORRUPT();
+ }
/* if it's invalid, skip over it (and backup 'i') */
@@ -349,7 +367,15 @@ int type;
if (cat->loadType == MCLoadAll) {
nl_catd res;
+
if ((res = loadSet(cat, set)) <= 0) {
+ for (j = 0; j < i; j++) {
+ set = cat->sets + j;
+ if (!set->invalid) {
+ free(set->data.str);
+ free(set->u.msgs);
+ }
+ }
free(cat->sets);
if (res == -1) NOSPACE();
CORRUPT();
OpenPOWER on IntegriCloud