Commit 0fcfb60d by Michael Procter

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.
parent 25dbcf34
...@@ -125,14 +125,12 @@ static int giterr_detach(git_error *cpy) ...@@ -125,14 +125,12 @@ static int giterr_detach(git_error *cpy)
if (!error) if (!error)
return -1; return -1;
if (error == &g_git_oom_error) {
cpy->message = git__strdup(error->message);
} else {
cpy->message = error->message; cpy->message = error->message;
error->message = NULL;
}
cpy->klass = error->klass; cpy->klass = error->klass;
if (error != &g_git_oom_error) {
error->message = NULL;
}
giterr_clear(); giterr_clear();
return 0; return 0;
...@@ -153,8 +151,13 @@ int giterr_capture(git_error_state *state, int error_code) ...@@ -153,8 +151,13 @@ int giterr_capture(git_error_state *state, int error_code)
int giterr_restore(git_error_state *state) int giterr_restore(git_error_state *state)
{ {
if (state && state->error_code && 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); set_error(state->error_msg.klass, state->error_msg.message);
}
}
else else
giterr_clear(); giterr_clear();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment