From a8672e2a99ec32f74b33ac49f7b647c36f68cda1 Mon Sep 17 00:00:00 2001
From: Joseph Hickey <joseph.p.hickey@nasa.gov>
Date: Fri, 6 Dec 2019 08:57:30 -0500
Subject: [PATCH] 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.
---
 fsw/src/sample_app.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/fsw/src/sample_app.c b/fsw/src/sample_app.c
index 5a4b027..7f5147d 100644
--- a/fsw/src/sample_app.c
+++ b/fsw/src/sample_app.c
@@ -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);