diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2006-02-17 19:12:42 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2006-02-17 19:12:42 +0000 |
commit | 57310fbca5be2f48208b646d5c7fd89635c212f8 (patch) | |
tree | 9808870ed62e1e87d8b112f3abfffa0d8ddd40b6 | |
parent | a0e69c38bf60b89139af37d462f09109263bbb0a (diff) |
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)) |