Skip to content

Commit 3998acb

Browse files
committed
contiki: Clear events pointer once consummed
This prevent potential access to invalid address, typically after a deletion. This change should be forwarded upstream, once contiki dependency is managed in modular way (using ref to upstream not code dump). Relate-to: SiliconLabsSoftware/z-wave-protocol-controller#94 Relate-to: UIC-3659 Relate-to: SiliconLabsSoftware/z-wave-engine-application-layer#17 Signed-off-by: Philippe Coval <[email protected]>
1 parent fb360ad commit 3998acb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

components/uic_contiki/core/sys/process.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ static void do_event(void) CC_REENTRANT_ARG
313313

314314
data = events[fevent].data;
315315
receiver = events[fevent].p;
316+
int fevent_copy = fevent; /* To be cleared once processed */
316317

317318
/* Since we have seen the new event, we move pointer upwards
318319
and decrese the number of events. */
@@ -342,6 +343,9 @@ static void do_event(void) CC_REENTRANT_ARG
342343
/* Make sure that the process actually is running. */
343344
call_process(receiver, ev, data);
344345
}
346+
/* Clear pointer (to potentially unreachable/freed data) */
347+
events[fevent_copy].data = NULL;
348+
events[fevent_copy].p = NULL;
345349
}
346350
}
347351
/*---------------------------------------------------------------------------*/

0 commit comments

Comments
 (0)