Skip to content

Commit 5a57f8f

Browse files
committed
remove panic from C invalid-argument callbacks
1 parent 4ae0e7e commit 5a57f8f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

secp256k1-sys/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ pub unsafe fn secp256k1_context_destroy(ctx: *mut Context) {
580580
///
581581
/// A callback function to be called when an illegal argument is passed to
582582
/// an API call. It will only trigger for violations that are mentioned
583-
/// explicitly in the header. **This will cause a panic**.
583+
/// explicitly in the header.
584584
///
585585
/// The philosophy is that these shouldn't be dealt with through a
586586
/// specific return value, as calling code should not have branches to deal with
@@ -600,13 +600,13 @@ pub unsafe extern "C" fn rustsecp256k1_v0_4_0_default_illegal_callback_fn(messag
600600
use core::str;
601601
let msg_slice = slice::from_raw_parts(message as *const u8, strlen(message));
602602
let msg = str::from_utf8_unchecked(msg_slice);
603-
panic!("[libsecp256k1] illegal argument. {}", msg);
603+
println!("[libsecp256k1] illegal argument. {}", msg);
604604
}
605605

606606
/// **This function is an override for the C function, this is the an edited version of the original description:**
607607
///
608608
/// A callback function to be called when an internal consistency check
609-
/// fails. **This will cause a panic**.
609+
/// fails.
610610
///
611611
/// This can only trigger in case of a hardware failure, miscompilation,
612612
/// memory corruption, serious bug in the library, or other error would can
@@ -623,7 +623,7 @@ pub unsafe extern "C" fn rustsecp256k1_v0_4_0_default_error_callback_fn(message:
623623
use core::str;
624624
let msg_slice = slice::from_raw_parts(message as *const u8, strlen(message));
625625
let msg = str::from_utf8_unchecked(msg_slice);
626-
panic!("[libsecp256k1] internal consistency check failed {}", msg);
626+
println!("[libsecp256k1] internal consistency check failed {}", msg);
627627
}
628628

629629
#[cfg(not(rust_secp_no_symbol_renaming))]

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ mod tests {
938938

939939
#[cfg(not(target_arch = "wasm32"))]
940940
#[test]
941-
#[should_panic]
941+
#[should_panic(expected = "assertion failed")]
942942
fn test_panic_raw_ctx() {
943943
let ctx_vrfy = Secp256k1::verification_only();
944944
let raw_ctx_verify_as_full = unsafe {Secp256k1::from_raw_all(ctx_vrfy.ctx)};

0 commit comments

Comments
 (0)