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-23 15:17:08 +0300
committerMichael Procter <michael@procter.org.uk>2015-08-03 17:23:17 +0300
commitc2f17bda074b2e5718456aed75fedd2196c8dc94 (patch)
treedf2e4db372075708a12ec433a7763afca025eca0
parent5ef4b86015309c157b20260905cb5d0c9bb47ca8 (diff)
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.
-rw-r--r--src/errors.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/errors.c b/src/errors.c
index 7a2600586..979602a2a 100644
--- a/src/errors.c
+++ b/src/errors.c
@@ -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;