add tests on morep used flag
authorMazet Laurent <laurent.mazet@thalesgroup.com>
Tue, 6 May 2025 15:28:31 +0000 (17:28 +0200)
committerMazet Laurent <laurent.mazet@thalesgroup.com>
Tue, 6 May 2025 15:28:31 +0000 (17:28 +0200)
morep.c

diff --git a/morep.c b/morep.c
index d150dcf59a38c35a246e970cfee2e5c7a4d333f0..41a39a053ac83e3d371976ded6665e00163e6fda 100644 (file)
--- a/morep.c
+++ b/morep.c
@@ -362,7 +362,8 @@ int MOREP_Send (int index, uint8_t msgtype, uint8_t *buffer, int len)
         VERBOSE (morep, ERROR, PRINTF ("too large buffer to send (%d)\n", len));
         return -1;
     }
-    if ((index < 0) || (index >= MAX_MOREP_NUMBER) || (MOREP_list[index] == NULL)) {
+    if ((index < 0) || (index >= MAX_MOREP_NUMBER) ||
+        (MOREP_list[index] == NULL) || (!MOREP_list[index]->used)) {
         VERBOSE (morep, ERROR, PRINTF ("incorrect MOREP descriptor (%d)\n", index));
         return -1;
     }
@@ -403,7 +404,7 @@ int MOREP_Receive (int index, uint8_t *msgtype, uint8_t *buffer, int *len)
 
     *msgtype = 0;
     if (((index < 0) || (index >= MAX_MOREP_NUMBER)) ||
-        (MOREP_list[index] == NULL)) {
+        (MOREP_list[index] == NULL) || (!MOREP_list[index]->used)) {
         VERBOSE (morep, ERROR, PRINTF ("incorrect MOREP descriptor (%d)\n", index));
         return -1;
     }