Added missing MPI_CHK around mpi functions
diff --git a/library/asn1write.c b/library/asn1write.c
index e50c17c..b1c98f4 100644
--- a/library/asn1write.c
+++ b/library/asn1write.c
@@ -85,7 +85,7 @@
         return( POLARSSL_ERR_ASN1_BUF_TOO_SMALL );
 
     (*p) -= len;
-    mpi_write_binary( X, *p, len );
+    MPI_CHK( mpi_write_binary( X, *p, len ) );
 
     // DER format assumes 2s complement for numbers, so the leftmost bit
     // should be 0 for positive numbers and 1 for negative numbers.
@@ -102,7 +102,10 @@
     ASN1_CHK_ADD( len, asn1_write_len( p, start, len ) );
     ASN1_CHK_ADD( len, asn1_write_tag( p, start, ASN1_INTEGER ) );
 
-    return( len );
+    ret = (int) len;
+
+cleanup:
+    return( ret );
 }
     
 int asn1_write_null( unsigned char **p, unsigned char *start )