mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-04 23:54:09 +00:00
Make giterr_restore aware of g_git_oom_error
Allow restoring a previously captured oom error, by detecting when the captured message pointer points to the static oom error message. This means there is no need to strdup the message in giterr_detach.
This commit is contained in:
parent
25dbcf3499
commit
0fcfb60dc4
19
src/errors.c
19
src/errors.c
@ -125,14 +125,12 @@ static int giterr_detach(git_error *cpy)
|
||||
if (!error)
|
||||
return -1;
|
||||
|
||||
if (error == &g_git_oom_error) {
|
||||
cpy->message = git__strdup(error->message);
|
||||
} else {
|
||||
cpy->message = error->message;
|
||||
error->message = NULL;
|
||||
}
|
||||
cpy->message = error->message;
|
||||
cpy->klass = error->klass;
|
||||
|
||||
if (error != &g_git_oom_error) {
|
||||
error->message = NULL;
|
||||
}
|
||||
giterr_clear();
|
||||
|
||||
return 0;
|
||||
@ -153,8 +151,13 @@ int giterr_capture(git_error_state *state, int error_code)
|
||||
|
||||
int giterr_restore(git_error_state *state)
|
||||
{
|
||||
if (state && state->error_code && state->error_msg.message)
|
||||
set_error(state->error_msg.klass, state->error_msg.message);
|
||||
if (state && state->error_code && state->error_msg.message) {
|
||||
if (state->error_msg.message == g_git_oom_error.message) {
|
||||
giterr_set_oom();
|
||||
} else {
|
||||
set_error(state->error_msg.klass, state->error_msg.message);
|
||||
}
|
||||
}
|
||||
else
|
||||
giterr_clear();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user