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