Hi
Following code in src/normal.c is wrong, since it calls 'vim_free(buf)'
which does nothing since it's inside 'if (buf == NULL)':
src/normal.c:
!!5565 buf = (char_u *)vim_realloc(buf, STRLEN(buf) + STRLEN(p) + 1);
!!5566 if (buf == NULL)
5567 {
!!5568 vim_free(buf);
5569 vim_free(p);
5570 return;
5571 }
Although unlikely to happen, it leaks memory since realloc() does
not free 'buf' if it fails.
Attached patch fixes it.
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 3331756e4232 src/normal.c
--- a/src/normal.c Thu Jul 08 22:27:55 2010 +0200
+++ b/src/normal.c Thu Jul 08 22:39:02 2010 +0200
@@ -5410,6 +5410,7 @@
{
char_u *ptr = NULL;
char_u *buf;
+ char_u *realloc_buf;
char_u *p;
char_u *kp; /* value of 'keywordprg' */
int kp_help; /* 'keywordprg' is ":help" */
@@ -5562,13 +5563,14 @@
vim_free(buf);
return;
}
- buf = (char_u *)vim_realloc(buf, STRLEN(buf) + STRLEN(p) + 1);
- if (buf == NULL)
+ realloc_buf = (char_u *)vim_realloc(buf, STRLEN(buf) + STRLEN(p) + 1);
+ if (realloc_buf == NULL)
{
vim_free(buf);
vim_free(p);
return;
}
+ buf = realloc_buf;
STRCAT(buf, p);
vim_free(p);
}