Skip to content

Commit

Permalink
Fix #28: Check return of CFE_TBL_GetAddress
Browse files Browse the repository at this point in the history
The code must not dereference the pointer unless the call
returned CFE_SUCCESS, otherwise the pointer is not valid.
  • Loading branch information
jphickey committed Dec 6, 2019
1 parent 92311e7 commit a8672e2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion fsw/src/sample_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,21 @@ void SAMPLE_ResetCounters( const SAMPLE_ResetCounters_t *Msg )
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void SAMPLE_ProcessCC( const SAMPLE_Process_t *Msg )
{
int32 status;
SampleTable_t *TblPtr;
const char *TableName = "SAMPLE_APP.SampleTable";

/* Sample Use of Table */
CFE_TBL_GetAddress((void *)&TblPtr,

status = CFE_TBL_GetAddress((void *)&TblPtr,
Sample_AppData.TblHandles[0]);

if (status != CFE_SUCCESS)
{
CFE_ES_WriteToSysLog("Sample App: Fail to get table pointer");
return;
}

CFE_ES_WriteToSysLog("Sample App: Table Value 1: %d Value 2: %d",
TblPtr->Int1,
TblPtr->Int2);
Expand Down

0 comments on commit a8672e2

Please sign in to comment.