Skip to content

Commit

Permalink
Fix #1840, Add Null check for CFE_ResourceId_FindNext
Browse files Browse the repository at this point in the history
  • Loading branch information
zanzaben committed Aug 18, 2021
1 parent a0c2de6 commit c25c8e5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions modules/core_api/fsw/inc/cfe_resourceid.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ uint32 CFE_ResourceId_GetSerial(CFE_ResourceId_t ResourceId);
* @param[in] CheckFunc a function to check if the given ID is available
* @returns Next ID value which does not map to a valid entry
* @retval #CFE_RESOURCEID_UNDEFINED if no open slots.
* @retval #CFE_ES_BAD_ARGUMENT @copybrief CFE_ES_BAD_ARGUMENT
*
*/
CFE_ResourceId_t CFE_ResourceId_FindNext(CFE_ResourceId_t StartId, uint32 TableSize,
Expand Down
7 changes: 6 additions & 1 deletion modules/resourceid/fsw/src/cfe_resourceid_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ int32 CFE_ResourceId_ToIndex(CFE_ResourceId_t Id, uint32 BaseValue, uint32 Table
*
* Function: CFE_ResourceId_FindNext
*
* Application-scope internal function
* Implemented per public API
* See description in header file for argument/return detail
*
*-----------------------------------------------------------------*/
Expand All @@ -121,6 +121,11 @@ CFE_ResourceId_t CFE_ResourceId_FindNext(CFE_ResourceId_t StartId, uint32 TableS
CFE_ResourceId_t CheckId;
bool IsTaken;

if (CheckFunc == NULL)
{
return CFE_ES_BAD_ARGUMENT;
}

ResourceType = CFE_ResourceId_GetBase(StartId);
Serial = CFE_ResourceId_GetSerial(StartId);

Expand Down

0 comments on commit c25c8e5

Please sign in to comment.