Skip to content

Commit

Permalink
secp256k1-sys: patch out checked_malloc
Browse files Browse the repository at this point in the history
  • Loading branch information
apoelstra committed Nov 6, 2023
1 parent 942a0e5 commit 7a0c60e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
8 changes: 3 additions & 5 deletions secp256k1-sys/depend/secp256k1/src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,9 @@ static const rustsecp256k1_v0_9_0_callback default_error_callback = {
#endif

static SECP256K1_INLINE void *checked_malloc(const rustsecp256k1_v0_9_0_callback* cb, size_t size) {
void *ret = malloc(size);
if (ret == NULL) {
rustsecp256k1_v0_9_0_callback_call(cb, "Out of memory");
}
return ret;
(void) cb;
(void) size;
return NULL;
}

#if defined(__BIGGEST_ALIGNMENT__)
Expand Down
10 changes: 10 additions & 0 deletions secp256k1-sys/depend/util.h.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
148,152c148,150
< void *ret = malloc(size);
< if (ret == NULL) {
< secp256k1_callback_call(cb, "Out of memory");
< }
< return ret;
---
> (void) cb;
> (void) size;
> return NULL;
1 change: 1 addition & 0 deletions secp256k1-sys/vendor-libsecp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ echo "$SOURCE_REV" >> ./secp256k1-HEAD-revision.txt
patch "$DIR/include/secp256k1.h" "./secp256k1.h.patch"
patch "$DIR/src/secp256k1.c" "./secp256k1.c.patch"
patch "$DIR/src/scratch_impl.h" "./scratch_impl.h.patch"
patch "$DIR/src/util.h" "./util.h.patch"

# Fix a linking error while cross-compiling to windowns with mingw
patch "$DIR/contrib/lax_der_parsing.c" "./lax_der_parsing.c.patch"
Expand Down

0 comments on commit 7a0c60e

Please sign in to comment.