[rtems commit] cpukit/libmisc/shell/main_edit.c: Fix use after free()
Joel Sherril
joel at rtems.org
Tue Nov 25 18:57:22 UTC 2014
Module: rtems
Branch: master
Commit: 4afa216ba878f08a030ab40cff57a852938ca18b
Changeset: http://git.rtems.org/rtems/commit/?id=4afa216ba878f08a030ab40cff57a852938ca18b
Author: Joel Sherrill <joel.sherrill at oarcorp.com>
Date: Mon Nov 24 14:12:54 2014 -0600
cpukit/libmisc/shell/main_edit.c: Fix use after free()
Coverity Id 1255353. Read from pointer after free().
---
cpukit/libmisc/shell/main_edit.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/cpukit/libmisc/shell/main_edit.c b/cpukit/libmisc/shell/main_edit.c
index 0feb828..a73bc0d 100644
--- a/cpukit/libmisc/shell/main_edit.c
+++ b/cpukit/libmisc/shell/main_edit.c
@@ -2147,7 +2147,15 @@ static void edit(struct editor *ed) {
case ctrl('s'): save_editor(ed); break;
case ctrl('p'): pipe_command(ed); break;
#endif
+#if defined(__rtems__)
+ /*
+ * Coverity spotted this as using ed after free() so changing
+ * the order of the statements.
+ */
+ case ctrl('w'): ed = ed->env->current; close_editor(ed); break;
+#else
case ctrl('w'): close_editor(ed); ed = ed->env->current; break;
+#endif
}
}
}
More information about the vc
mailing list