summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorVincent Labrecque <vincent@cvs.openbsd.org>2003-09-22 23:03:08 +0000
committerVincent Labrecque <vincent@cvs.openbsd.org>2003-09-22 23:03:08 +0000
commit76f752d949fea53489f80bf9117b6b61a3ca7910 (patch)
treec91ecb9da3fbb0dea3f63f7e3a57ab38b3b3776a /usr.bin
parent4085d09b43964c8ebb56763bfe49d52a1ff86b70 (diff)
fix leak on realloc failure
ok henning tedu
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mg/extend.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.bin/mg/extend.c b/usr.bin/mg/extend.c
index 609021ebd2d..9f3f1229380 100644
--- a/usr.bin/mg/extend.c
+++ b/usr.bin/mg/extend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: extend.c,v 1.29 2002/09/15 14:48:50 vincent Exp $ */
+/* $OpenBSD: extend.c,v 1.30 2003/09/22 23:03:07 vincent Exp $ */
/*
* Extended (M-X) commands, rebinding, and startup file processing.
@@ -91,7 +91,7 @@ remap(KEYMAP *curmap, /* pointer to the map being changed */
)
{
int i, n1, n2, nold;
- KEYMAP *mp;
+ KEYMAP *mp, *newmap;
PF *pfp;
MAP_ELEMENT *mep;
@@ -136,9 +136,11 @@ remap(KEYMAP *curmap, /* pointer to the map being changed */
ele->k_base = c;
ele->k_funcp = pfp;
} else {
- if (curmap->map_num >= curmap->map_max &&
- (curmap = reallocmap(curmap)) == NULL)
- return FALSE;
+ if (curmap->map_num >= curmap->map_max) {
+ if ((newmap = reallocmap(curmap)) == NULL)
+ return FALSE;
+ curmap = newmap;
+ }
if ((pfp = malloc(sizeof(PF))) == NULL) {
ewprintf("Out of memory");
return FALSE;