Skip to content

Commit f4310fd

Browse files
committed
updated for version 7.3.169
Problem: Freeing memory already freed, warning from static code analyzer. Solution: Initialize pointers to NULL, correct use of "mustfree". (partly by Dominique Pelle)
1 parent f6a8ba6 commit f4310fd

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/misc1.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3505,7 +3505,7 @@ init_homedir()
35053505
if (enc_utf8 && var != NULL)
35063506
{
35073507
int len;
3508-
char_u *pp;
3508+
char_u *pp = NULL;
35093509

35103510
/* Convert from active codepage to UTF-8. Other conversions are
35113511
* not done, because they would fail for non-ASCII characters. */
@@ -3872,11 +3872,13 @@ expand_env_esc(srcp, dst, dstlen, esc, one, startstr)
38723872
* Vim's version of getenv().
38733873
* Special handling of $HOME, $VIM and $VIMRUNTIME.
38743874
* Also does ACP to 'enc' conversion for Win32.
3875+
* "mustfree" is set to TRUE when returned is allocated, it must be
3876+
* initialized to FALSE by the caller.
38753877
*/
38763878
char_u *
38773879
vim_getenv(name, mustfree)
38783880
char_u *name;
3879-
int *mustfree; /* set to TRUE when returned is allocated */
3881+
int *mustfree;
38803882
{
38813883
char_u *p;
38823884
char_u *pend;
@@ -3898,7 +3900,7 @@ vim_getenv(name, mustfree)
38983900
if (enc_utf8)
38993901
{
39003902
int len;
3901-
char_u *pp;
3903+
char_u *pp = NULL;
39023904

39033905
/* Convert from active codepage to UTF-8. Other conversions are
39043906
* not done, because they would fail for non-ASCII characters. */
@@ -3942,15 +3944,15 @@ vim_getenv(name, mustfree)
39423944
if (enc_utf8)
39433945
{
39443946
int len;
3945-
char_u *pp;
3947+
char_u *pp = NULL;
39463948

39473949
/* Convert from active codepage to UTF-8. Other conversions
39483950
* are not done, because they would fail for non-ASCII
39493951
* characters. */
39503952
acp_to_enc(p, (int)STRLEN(p), &pp, &len);
39513953
if (pp != NULL)
39523954
{
3953-
if (mustfree)
3955+
if (*mustfree)
39543956
vim_free(p);
39553957
p = pp;
39563958
*mustfree = TRUE;

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,8 @@ static char *(features[]) =
714714

715715
static int included_patches[] =
716716
{ /* Add new patch number below this line */
717+
/**/
718+
169,
717719
/**/
718720
168,
719721
/**/

0 commit comments

Comments
 (0)