sap_socket->onRequestComplete(t,e,response,responselen);
} else {
RLOGE("Invalid socket id");
- if (request->curr->payload) {
- free(request->curr->payload);
+ if (request->curr) {
+ free(request->curr);
}
- free(request->curr);
free(request);
}
}
void RilSapSocket::onRequestComplete(RIL_Token t, RIL_Errno e, void *response,
size_t response_len) {
SapSocketRequest* request= (SapSocketRequest*)t;
+
+ if (!request || !request->curr) {
+ RLOGE("RilSapSocket::onRequestComplete: request/request->curr is NULL");
+ return;
+ }
+
MsgHeader *hdr = request->curr;
MsgHeader rsp;
Return<void> SapImpl::addPayloadAndDispatchRequest(MsgHeader *msg, uint16_t reqLen,
uint8_t *reqPtr) {
- msg->payload = (pb_bytes_array_t *)malloc(sizeof(pb_bytes_array_t) - 1 + reqLen);
- if (msg->payload == NULL) {
+ pb_bytes_array_t *payload = (pb_bytes_array_t *) malloc(sizeof(pb_bytes_array_t) - 1 + reqLen);
+ if (payload == NULL) {
sendFailedResponse(msg->id, msg->token, 2, reqPtr, msg);
return Void();
}
+
+ msg->payload = payload;
msg->payload->size = reqLen;
memcpy(msg->payload->bytes, reqPtr, reqLen);
sapSocket->dispatchRequest(msg);
} else {
RLOGE("SapImpl::addPayloadAndDispatchRequest: sapSocket is null");
- sendFailedResponse(msg->id, msg->token, 3, msg->payload, reqPtr, msg);
+ sendFailedResponse(msg->id, msg->token, 3, payload, reqPtr, msg);
return Void();
}
free(msg->payload);