Avoid unnecessary xxx_copy() calls
The call would anyway check for pointer equality and return early, but it
doesn't hurt to save a function call, and also this follows more uniformly the
pattern that those two lines go together:
#if defined(MBEDTLS_ECP_RESTARTBLE)
if( rs_ctx != NULL && ...
diff --git a/library/ecdsa.c b/library/ecdsa.c
index f3b3cf2..835d3de 100644
--- a/library/ecdsa.c
+++ b/library/ecdsa.c
@@ -353,7 +353,8 @@
while( mbedtls_mpi_cmp_int( s, 0 ) == 0 );
#if defined(MBEDTLS_ECP_RESTARTABLE)
- mbedtls_mpi_copy( r, pr );
+ if( rs_ctx != NULL && rs_ctx->sig != NULL )
+ mbedtls_mpi_copy( r, pr );
#endif
cleanup: