Hi
Attached patch fixes a bug in vim_getenv() found
with cppcheck static analyzer:
$ cd vim/src ; cppcheck -f -I proto misc1.c
[misc1.c:3956]: (error) Possible null pointer dereference: mustfree -
otherwise it is redundant to check if mustfree is null at line 3953
Reading the code, I'd expect invalid memory free to possibly happen
on Windows. I don't have a Windows computer to test it, but
the patch is simple anyway.
Regards
-- Dominique
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff -r 987cd9455925 src/misc1.c
--- a/src/misc1.c Mon Apr 11 21:35:11 2011 +0200
+++ b/src/misc1.c Wed Apr 13 20:56:08 2011 +0200
@@ -3950,7 +3950,7 @@
acp_to_enc(p, (int)STRLEN(p), &pp, &len);
if (pp != NULL)
{
- if (mustfree)
+ if (*mustfree)
vim_free(p);
p = pp;
*mustfree = TRUE;