Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 64e6b5b

Browse files
committed
fix memory leak in refspec.c on errors.
1 parent 4a0313b commit 64e6b5b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/refspec.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ int git_refspec__parse(git_refspec *refspec, const char *input, bool is_fetch)
142142
giterr_set(
143143
GITERR_INVALID,
144144
"'%s' is not a valid refspec.", input);
145+
git_refspec__free(refspec);
145146
return -1;
146147
}
147148

@@ -153,6 +154,8 @@ void git_refspec__free(git_refspec *refspec)
153154
git__free(refspec->src);
154155
git__free(refspec->dst);
155156
git__free(refspec->string);
157+
158+
memset(refspec, 0x0, sizeof(git_refspec));
156159
}
157160

158161
const char *git_refspec_src(const git_refspec *refspec)

0 commit comments

Comments
 (0)