diff --git a/script/user_nodefs.h b/script/user_nodefs.h index 5b0be81a3..3c06a706d 100644 --- a/script/user_nodefs.h +++ b/script/user_nodefs.h @@ -6,6 +6,7 @@ */ #nodef GITERR_CHECK_ALLOC(ptr) if (ptr == NULL) { __coverity_panic__(); } +#nodef GITERR_CHECK_ALLOC_BUF(buf) if (buf == NULL || git_buf_oom(buf)) { __coverity_panic__(); } #nodef GITERR_CHECK_ALLOC_ADD(out, one, two) \ if (GIT_ADD_SIZET_OVERFLOW(out, one, two)) { __coverity_panic__(); } diff --git a/src/common.h b/src/common.h index bc4bdd856..9abd605cb 100644 --- a/src/common.h +++ b/src/common.h @@ -89,6 +89,11 @@ */ #define GITERR_CHECK_ALLOC(ptr) if (ptr == NULL) { return -1; } +/** + * Check a buffer allocation result, returning -1 if it failed. + */ +#define GITERR_CHECK_ALLOC_BUF(buf) if ((void *)(buf) == NULL || git_buf_oom(buf)) { return -1; } + /** * Check a return value and propagate result if non-zero. */