MPS Reader Tests: Test feed() of NULL buffer

Signed-off-by: Hanno Becker <hanno.becker@arm.com>
diff --git a/tests/suites/test_suite_mps.data b/tests/suites/test_suite_mps.data
index a1a6e5c..158302b 100644
--- a/tests/suites/test_suite_mps.data
+++ b/tests/suites/test_suite_mps.data
@@ -117,3 +117,6 @@
 
 MPS Reader: Pausing, inconsistent continuation, #8
 mbedtls_reader_inconsistent_usage:8
+
+MPS Reader: Feed with invalid buffer (NULL)
+mbedtls_mps_reader_feed_empty:0
diff --git a/tests/suites/test_suite_mps.function b/tests/suites/test_suite_mps.function
index 6f2eb65..f2040f8 100644
--- a/tests/suites/test_suite_mps.function
+++ b/tests/suites/test_suite_mps.function
@@ -1059,3 +1059,41 @@
     mbedtls_reader_free( &rd );
 }
 /* END_CASE */
+
+/* BEGIN_CASE depends_on:TEST_SUITE_MPS_READER */
+void mbedtls_mps_reader_feed_empty( int option )
+{
+    /* This test exercises the behaviour of the reader when it is
+     * fed a NULL buffer. */
+    unsigned char buf[100];
+    unsigned char *tmp;
+    mbedtls_reader rd;
+    for( int i=0; (unsigned) i < sizeof( buf ); i++ )
+        buf[i] = (unsigned char) i;
+
+    /* Preparation (lower layer) */
+    mbedtls_reader_init( &rd, NULL, 0 );
+    switch( option )
+    {
+        case 0: /* NULL buffer */
+            TEST_ASSERT( mbedtls_reader_feed( &rd, NULL, sizeof( buf ) ) ==
+                         MBEDTLS_ERR_MPS_READER_INVALID_ARG );
+            break;
+
+        default:
+            TEST_ASSERT( 0 );
+            break;
+    }
+    /* Subsequent feed-calls should still succeed. */
+    TEST_ASSERT( mbedtls_reader_feed( &rd, buf, sizeof( buf ) ) == 0 );
+
+    /* Consumption (upper layer) */
+    TEST_ASSERT( mbedtls_reader_get( &rd, 100, &tmp, NULL ) == 0 );
+    ASSERT_COMPARE( tmp, 100, buf, 100 );
+    TEST_ASSERT( mbedtls_reader_commit( &rd ) == 0 );
+
+    /* Wrapup */
+    TEST_ASSERT( mbedtls_reader_reclaim( &rd, NULL ) == 0 );
+    mbedtls_reader_free( &rd );
+}
+/* END_CASE */