From 7a0c60edcd976bd55abf1490aa8454ef2d1a7caf Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Mon, 6 Nov 2023 14:38:49 +0000 Subject: [PATCH] secp256k1-sys: patch out checked_malloc --- secp256k1-sys/depend/secp256k1/src/util.h | 8 +++----- secp256k1-sys/depend/util.h.patch | 10 ++++++++++ secp256k1-sys/vendor-libsecp.sh | 1 + 3 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 secp256k1-sys/depend/util.h.patch diff --git a/secp256k1-sys/depend/secp256k1/src/util.h b/secp256k1-sys/depend/secp256k1/src/util.h index 613901e..0835b3f 100644 --- a/secp256k1-sys/depend/secp256k1/src/util.h +++ b/secp256k1-sys/depend/secp256k1/src/util.h @@ -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__) diff --git a/secp256k1-sys/depend/util.h.patch b/secp256k1-sys/depend/util.h.patch new file mode 100644 index 0000000..7644825 --- /dev/null +++ b/secp256k1-sys/depend/util.h.patch @@ -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; diff --git a/secp256k1-sys/vendor-libsecp.sh b/secp256k1-sys/vendor-libsecp.sh index e486412..ed437fc 100755 --- a/secp256k1-sys/vendor-libsecp.sh +++ b/secp256k1-sys/vendor-libsecp.sh @@ -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"