Fix null pointer dereference in the RSA module.

Introduced null pointer checks in mbedtls_rsa_rsaes_pkcs1_v15_encrypt
diff --git a/ChangeLog b/ChangeLog
index 1581a3a..9a3b8a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,8 @@
      Follath. #309
    * Fix issue in Makefile that prevented building using armar. #386
    * Fix issue that caused a hang up when generating RSA keys of odd bitlength
+   * Fix bug in mbedtls_rsa_rsaes_pkcs1_v15_encrypt that made null pointer
+     dereference possible.
 
 Changes
    * On ARM platforms, when compiling with -O0 with GCC, Clang or armcc5,
diff --git a/library/rsa.c b/library/rsa.c
index d86fbc5..16114ac 100644
--- a/library/rsa.c
+++ b/library/rsa.c
@@ -586,7 +586,8 @@
     if( mode == RSA_PRIVATE && ctx->padding != RSA_PKCS_V15 )
         return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
 
-    if( f_rng == NULL )
+    // We don't check p_rng because it won't be dereferenced here
+    if( f_rng == NULL || input == NULL || output == NULL )
         return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
 
     olen = ctx->len;