Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[CommandHandler] Fix potential NULL pointer dereference
Also re-ordered the code a bit. There is no point trying to
figure out the statusType when we cannot and the NULL check at the end is
not needed anymore.

Fixes: CID#58940

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Sep 20, 2014
1 parent 20cb210 commit d16c2d1
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/CommandHandler.cpp
Expand Up @@ -134,8 +134,15 @@ void CommandHandler::handleStatus(StatusParams* aStatusParams )
{
FUNCTION_CALL_TRACE;

ResponseStatusCode statusCode = aStatusParams->data;
StatusCodeType statusType = getStatusType(statusCode);
ResponseStatusCode statusCode;
StatusCodeType statusType;

if (aStatusParams != NULL)
statusCode = aStatusParams->data;
else
return;

statusType = getStatusType(statusCode);

switch (statusType) {
case INFORMATIONAL:
Expand Down Expand Up @@ -171,10 +178,9 @@ void CommandHandler::handleStatus(StatusParams* aStatusParams )
}
}

if (aStatusParams != NULL &&
( aStatusParams->cmd == SYNCML_ELEMENT_ADD ||
aStatusParams->cmd == SYNCML_ELEMENT_REPLACE ||
aStatusParams->cmd == SYNCML_ELEMENT_DELETE ) ) {
if ( aStatusParams->cmd == SYNCML_ELEMENT_ADD ||
aStatusParams->cmd == SYNCML_ELEMENT_REPLACE ||
aStatusParams->cmd == SYNCML_ELEMENT_DELETE ) {
emit itemAcknowledged( aStatusParams->msgRef, aStatusParams->cmdRef, aStatusParams->sourceRef );
}

Expand Down

0 comments on commit d16c2d1

Please sign in to comment.