diff --git a/modules/sb/fsw/src/cfe_sb_api.c b/modules/sb/fsw/src/cfe_sb_api.c index 377179f4e..b5e0c6b0e 100644 --- a/modules/sb/fsw/src/cfe_sb_api.c +++ b/modules/sb/fsw/src/cfe_sb_api.c @@ -1458,17 +1458,18 @@ CFE_Status_t CFE_SB_ReleaseMessageBuffer(CFE_SB_Buffer_t *BufPtr) return CFE_SB_BAD_ARGUMENT; } - CFE_SB_LockSharedData(__func__, __LINE__); - Status = CFE_SB_ZeroCopyBufferValidate(BufPtr, &BufDscPtr); + if (Status == CFE_SUCCESS) { + CFE_SB_LockSharedData(__func__, __LINE__); + /* Clear the ownership app ID and decrement use count (may also free) */ BufDscPtr->AppId = CFE_ES_APPID_UNDEFINED; CFE_SB_DecrBufUseCnt(BufDscPtr); - } - CFE_SB_UnlockSharedData(__func__, __LINE__); + CFE_SB_UnlockSharedData(__func__, __LINE__); + } return Status; }