diff options
author | 2003-09-28 19:17:21 +0000 | |
---|---|---|
committer | 2003-09-28 19:17:21 +0000 | |
commit | 16a7b6502965b46ddd17092d29b22aca17a73b23 (patch) | |
tree | afad7337bb958b420d615dcd1f44e79242130ef8 | |
parent | Fix error check for array store operator. (diff) | |
download | wireguard-openbsd-16a7b6502965b46ddd17092d29b22aca17a73b23.tar.xz wireguard-openbsd-16a7b6502965b46ddd17092d29b22aca17a73b23.zip |
Free memory after a failing realloc.
-rw-r--r-- | usr.bin/dc/mem.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/dc/mem.c b/usr.bin/dc/mem.c index 35a79d719c4..0240b9628a5 100644 --- a/usr.bin/dc/mem.c +++ b/usr.bin/dc/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.1 2003/09/19 17:58:25 otto Exp $ */ +/* $OpenBSD: mem.c,v 1.2 2003/09/28 19:17:21 otto Exp $ */ /* * Copyright (c) 2003, Otto Moerbeek <otto@drijf.net> @@ -17,7 +17,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: mem.c,v 1.1 2003/09/19 17:58:25 otto Exp $"; +static const char rcsid[] = "$OpenBSD: mem.c,v 1.2 2003/09/28 19:17:21 otto Exp $"; #endif /* not lint */ #include <ssl/err.h> @@ -77,8 +77,10 @@ brealloc(void *p, size_t sz) void *q; q = realloc(p, sz); - if (q == NULL) + if (q == NULL) { + free(p); err(1, "realloc failed"); + } return q; } |