diff options
author | 2006-02-17 19:12:41 +0000 | |
---|---|---|
committer | 2006-02-17 19:12:41 +0000 | |
commit | 9c72fb1f674055cdd286873e2221a8dcaa27656c (patch) | |
tree | 2c744a2405a873d1778ab7977185e98855ac763c | |
parent | espie@ backed out the library part of brad's commit which broke stuff, (diff) | |
download | wireguard-openbsd-9c72fb1f674055cdd286873e2221a8dcaa27656c.tar.xz wireguard-openbsd-9c72fb1f674055cdd286873e2221a8dcaa27656c.zip |
Fix use after free. Problem hunted down by wilfried@; ok fgsch@
millert@
-rw-r--r-- | usr.bin/vi/vi/v_ex.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.bin/vi/vi/v_ex.c b/usr.bin/vi/vi/v_ex.c index 325e0a1d917..9024817d763 100644 --- a/usr.bin/vi/vi/v_ex.c +++ b/usr.bin/vi/vi/v_ex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v_ex.c,v 1.6 2005/10/17 19:12:16 otto Exp $ */ +/* $OpenBSD: v_ex.c,v 1.7 2006/02/17 19:12:41 otto Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -200,10 +200,14 @@ v_switch(sp, vp) * Try the alternate file name, then the previous file * name. Use the real name, not the user's current name. */ - if ((name = sp->alt_name) == NULL) { + if (sp->alt_name == NULL) { msgq(sp, M_ERR, "180|No previous file to edit"); return (1); } + if ((name = strdup(sp->alt_name)) == NULL) { + msgq(sp, M_SYSERR, NULL); + return (1); + } /* If autowrite is set, write out the file. */ if (file_m1(sp, 0, FS_ALL)) |