diff --git a/src/inbound_group_session.c b/src/inbound_group_session.c
index ed313a0a298defa731aa005001fc7a4516655874..a54e55f0e91dd6eb2427a858833770a3432bea12 100644
--- a/src/inbound_group_session.c
+++ b/src/inbound_group_session.c
@@ -287,7 +287,9 @@ static size_t _decrypt(
         return (size_t)-1;
     }
 
-    *message_index = decoded_results.message_index;
+    if (message_index != NULL) {
+        *message_index = decoded_results.message_index;
+    }
 
     /* verify the signature. We could do this before decoding the message, but
      * we allow for the possibility of future protocol versions which use a