Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Procter <michael@procter.org.uk>2015-07-27 12:10:18 +0300
committerMichael Procter <michael@procter.org.uk>2015-08-03 17:23:17 +0300
commit0fcfb60dc4f5e6cfd91c902d844f5d8665a5c1a7 (patch)
tree3ad17bbf9a474ede24b5414fad33e9c09573ff82
parent25dbcf34993cad3cdc3981f1ed394d3374fb640f (diff)
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.
-rw-r--r--src/errors.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/errors.c b/src/errors.c
index 95c62176c..f10430c10 100644
--- a/src/errors.c
+++ b/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();