@@ -255,6 +255,52 @@ extern "C" {
255
255
) -> c_int ;
256
256
}
257
257
258
+
259
+ #[ no_mangle]
260
+ /// **This function is an override for the C function, this is the an edited version of the original description:**
261
+ ///
262
+ /// A callback function to be called when an illegal argument is passed to
263
+ /// an API call. It will only trigger for violations that are mentioned
264
+ /// explicitly in the header. **This will cause a panic**.
265
+ ///
266
+ /// The philosophy is that these shouldn't be dealt with through a
267
+ /// specific return value, as calling code should not have branches to deal with
268
+ /// the case that this code itself is broken.
269
+ ///
270
+ /// On the other hand, during debug stage, one would want to be informed about
271
+ /// such mistakes, and the default (crashing) may be inadvisable.
272
+ /// When this callback is triggered, the API function called is guaranteed not
273
+ /// to cause a crash, though its return value and output arguments are
274
+ /// undefined.
275
+ ///
276
+ /// See also secp256k1_default_error_callback_fn.
277
+ ///
278
+ pub extern "C" fn secp256k1_default_illegal_callback_fn ( _message : * const c_char , _data : * mut c_void ) {
279
+ // Do we need to deref the message and print it? if so without std we'll need to use `strlen`
280
+ panic ! ( "[libsecp256k1] illegal argument." ) ;
281
+ }
282
+
283
+ #[ no_mangle]
284
+ /// **This function is an override for the C function, this is the an edited version of the original description:**
285
+ ///
286
+ /// A callback function to be called when an internal consistency check
287
+ /// fails. **This will cause a panic**.
288
+ ///
289
+ /// This can only trigger in case of a hardware failure, miscompilation,
290
+ /// memory corruption, serious bug in the library, or other error would can
291
+ /// otherwise result in undefined behaviour. It will not trigger due to mere
292
+ /// incorrect usage of the API (see secp256k1_default_illegal_callback_fn
293
+ /// for that). After this callback returns, anything may happen, including
294
+ /// crashing.
295
+ ///
296
+ /// See also secp256k1_default_illegal_callback_fn.
297
+ ///
298
+ pub extern "C" fn secp256k1_default_error_callback_fn ( _message : * const c_char , _data : * mut c_void ) {
299
+ // Do we need to deref the message and print it? if so without std we'll need to use `strlen`
300
+ panic ! ( "[libsecp256k1] internal consistency check failed." ) ;
301
+ }
302
+
303
+
258
304
#[ cfg( feature = "fuzztarget" ) ]
259
305
mod fuzz_dummy {
260
306
extern crate std;
0 commit comments