mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
fix(git): fix resource leak in countCommits on exception
Replace RETURN_IF_EXCEPTION with explicit cleanup that frees the git_revwalk before returning when toWTFString throws an exception. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -792,7 +792,10 @@ JSC_DEFINE_HOST_FUNCTION(jsGitRepositoryCountCommits, (JSC::JSGlobalObject * lex
|
||||
}
|
||||
|
||||
WTF::String rangeString = rangeValue.toWTFString(lexicalGlobalObject);
|
||||
RETURN_IF_EXCEPTION(scope, {});
|
||||
if (scope.exception()) [[unlikely]] {
|
||||
git_revwalk_free(walk);
|
||||
return JSC::JSValue::encode(JSC::jsUndefined());
|
||||
}
|
||||
WTF::CString rangeCString = rangeString.utf8();
|
||||
|
||||
error = git_revwalk_push_range(walk, rangeCString.data());
|
||||
|
||||
Reference in New Issue
Block a user