mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-05 22:55:47 +00:00
Ensure static oom error message not detached
Error messages that are detached are assumed to be dynamically allocated. Passing a pointer to the static oom error message can cause an attempt to free the static buffer later. This change checks if the oom error message is about to be detached and detaches a copy instead.
This commit is contained in:
parent
5ef4b86015
commit
c2f17bda07
@ -125,10 +125,14 @@ int giterr_detach(git_error *cpy)
|
||||
if (!error)
|
||||
return -1;
|
||||
|
||||
cpy->message = error->message;
|
||||
if (error == &g_git_oom_error) {
|
||||
cpy->message = git__strdup(error->message);
|
||||
} else {
|
||||
cpy->message = error->message;
|
||||
error->message = NULL;
|
||||
}
|
||||
cpy->klass = error->klass;
|
||||
|
||||
error->message = NULL;
|
||||
giterr_clear();
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user