summaryrefslogtreecommitdiff
path: root/lib/libc/time
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1998-08-14 21:39:45 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1998-08-14 21:39:45 +0000
commitfbe7a4e21ce2effe646980ca1214c125d94c70fd (patch)
tree50eb4ae3c83a05be96515dfbe68af415625afbfa /lib/libc/time
parenteef299572b3aae714384affd3dae3292c7325f78 (diff)
realloc repair
Diffstat (limited to 'lib/libc/time')
-rw-r--r--lib/libc/time/ialloc.c4
-rw-r--r--lib/libc/time/strftime.c12
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/libc/time/ialloc.c b/lib/libc/time/ialloc.c
index 78ce8e6b54f..39bb4db7dce 100644
--- a/lib/libc/time/ialloc.c
+++ b/lib/libc/time/ialloc.c
@@ -1,6 +1,6 @@
#if defined(LIBC_SCCS) && !defined(lint) && !defined(NOID)
static char elsieid[] = "@(#)ialloc.c 8.29";
-static char rcsid[] = "$OpenBSD: ialloc.c,v 1.4 1998/01/18 23:24:52 millert Exp $";
+static char rcsid[] = "$OpenBSD: ialloc.c,v 1.5 1998/08/14 21:39:43 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
/*LINTLIBRARY*/
@@ -53,6 +53,8 @@ const char * const new;
if ((result = irealloc(old, oldsize + newsize + 1)) != NULL)
if (new != NULL)
(void) strcpy(result + oldsize, new);
+ else
+ free(old);
return result;
}
diff --git a/lib/libc/time/strftime.c b/lib/libc/time/strftime.c
index 892c31446cd..321d71fafc1 100644
--- a/lib/libc/time/strftime.c
+++ b/lib/libc/time/strftime.c
@@ -1,6 +1,6 @@
#if defined(LIBC_SCCS) && !defined(lint) && !defined(NOID)
static char elsieid[] = "@(#)strftime.c 7.57";
-static char *rcsid = "$OpenBSD: strftime.c,v 1.4 1998/07/06 19:00:38 millert Exp $";
+static char *rcsid = "$OpenBSD: strftime.c,v 1.5 1998/08/14 21:39:44 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#include "private.h"
@@ -557,6 +557,7 @@ _loc P((void))
int fd;
int oldsun; /* "...ain't got nothin' to do..." */
char * lbuf;
+ char * nlbuf;
char * name;
char * p;
const char ** ap;
@@ -613,10 +614,15 @@ _loc P((void))
goto bad_locale;
bufsize = namesize + st.st_size;
locale_buf = NULL;
- lbuf = (lbuf == NULL || lbuf == locale_buf_C) ?
+ nlbuf = (lbuf == NULL || lbuf == locale_buf_C) ?
malloc(bufsize) : realloc(lbuf, bufsize);
- if (lbuf == NULL)
+ if (nlbuf == NULL) {
+ if (lbuf)
+ free(lbuf);
+ lbuf = NULL;
goto bad_locale;
+ }
+ lbuf = nlbuf;
(void) strcpy(lbuf, name);
p = lbuf + namesize;
plim = p + st.st_size;