patch 8.1.2091: double free when memory allocation fails
Problem: Double free when memory allocation fails. (Zu-Ming Jiang)
Solution: Use VIM_CLEAR() instead of vim_free(). (closes #4991)
diff --git a/src/getchar.c b/src/getchar.c
index 1056e93..fcdc639 100644
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -1296,11 +1296,11 @@
if (typebuf.tb_buf == typebuf_init)
internal_error("Free typebuf 1");
else
- vim_free(typebuf.tb_buf);
+ VIM_CLEAR(typebuf.tb_buf);
if (typebuf.tb_noremap == noremapbuf_init)
internal_error("Free typebuf 2");
else
- vim_free(typebuf.tb_noremap);
+ VIM_CLEAR(typebuf.tb_noremap);
}
/*