Skip to content

Commit 693d75f

Browse files
jphickeyskliper
authored andcommitted
Fix #28: Check return of CFE_TBL_GetAddress
The code must not dereference the pointer unless the call returned CFE_SUCCESS, otherwise the pointer is not valid.
1 parent 3491a24 commit 693d75f

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

fsw/src/sample_app.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,13 +430,22 @@ void SAMPLE_ResetCounters( const SAMPLE_ResetCounters_t *Msg )
430430
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
431431
void SAMPLE_ProcessCC( const SAMPLE_Process_t *Msg )
432432
{
433+
int32 status;
433434
SampleTable_t *TblPtr;
434435
const char *TableName = "SAMPLE_APP.SampleTable";
435436

436437
/* Sample Use of Table */
437-
CFE_TBL_GetAddress((void *)&TblPtr,
438+
439+
status = CFE_TBL_GetAddress((void *)&TblPtr,
438440
Sample_AppData.TblHandles[0]);
439441

442+
if (status != CFE_SUCCESS)
443+
{
444+
CFE_ES_WriteToSysLog("Sample App: Fail to get table address: 0x%08lx",
445+
(unsigned long)status);
446+
return;
447+
}
448+
440449
CFE_ES_WriteToSysLog("Sample App: Table Value 1: %d Value 2: %d",
441450
TblPtr->Int1,
442451
TblPtr->Int2);

0 commit comments

Comments
 (0)