diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2015-08-03 16:50:27 -0500 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2015-08-03 19:44:51 -0400 |
commit | ef4857c2b3d4a61fd1d840199afc92eaf2e15345 (patch) | |
tree | 2e02b7fcc28a00c0eede602b8880b83a9fd35c77 /src/common.h | |
parent | 854b701c8a799a484ef48d8b595601ab29876b57 (diff) | |
download | libgit2-ef4857c2b3d4a61fd1d840199afc92eaf2e15345.tar.gz |
errors: tighten up git_error_state OOMs a bit more
When an error state is an OOM, make sure that we treat is specially
and do not try to free it.
Diffstat (limited to 'src/common.h')
-rw-r--r-- | src/common.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/common.h b/src/common.h index 2b1dedc01..6dca36fbd 100644 --- a/src/common.h +++ b/src/common.h @@ -141,20 +141,25 @@ void giterr_system_set(int code); * Structure to preserve libgit2 error state */ typedef struct { - int error_code; + int error_code; + unsigned int oom : 1; git_error error_msg; } git_error_state; /** * Capture current error state to restore later, returning error code. - * If `error_code` is zero, this does nothing and returns zero. + * If `error_code` is zero, this does not clear the current error state. + * You must either restore this error state, or free it. */ -int giterr_capture(git_error_state *state, int error_code); +extern int giterr_state_capture(git_error_state *state, int error_code); /** * Restore error state to a previous value, returning saved error code. */ -int giterr_restore(git_error_state *state); +extern int giterr_state_restore(git_error_state *state); + +/** Free an error state. */ +extern void giterr_state_free(git_error_state *state); /** * Check a versioned structure for validity |