Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 398f561

Browse files
committed
findSubsystemObjectFromConfigurableElement: return nullptr if no object found
This function was improperly returning the latest candidate in case of failure instead of returning a nullptr. This led the caller to use the returned pointer even if it was not correct. Signed-off-by: David Wagner <[email protected]>
1 parent 3d38fee commit 398f561

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

parameter/Subsystem.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,21 +203,20 @@ const CSubsystemObject *CSubsystem::findSubsystemObjectFromConfigurableElement(
203203
const CInstanceConfigurableElement *pInstanceConfigurableElement) const
204204
{
205205

206-
const CSubsystemObject *pSubsystemObject = NULL;
207-
208206
list<CSubsystemObject *>::const_iterator it;
209207
for (it = _subsystemObjectList.begin(); it != _subsystemObjectList.end(); ++it) {
210208

211209
// Check if one of the SubsystemObjects is associated with a ConfigurableElement
212210
// corresponding to the expected one
213-
pSubsystemObject = *it;
211+
const CSubsystemObject *pSubsystemObject = *it;
212+
214213
if (pSubsystemObject->getConfigurableElement() == pInstanceConfigurableElement) {
215214

216-
break;
215+
return pSubsystemObject;
217216
}
218217
}
219218

220-
return pSubsystemObject;
219+
return nullptr;
221220
}
222221

223222
void CSubsystem::findSubsystemLevelMappingKeyValue(

0 commit comments

Comments
 (0)