Index: build/chrome/cackey-chrome-init.cc ================================================================== --- build/chrome/cackey-chrome-init.cc +++ build/chrome/cackey-chrome-init.cc @@ -28,11 +28,11 @@ corePointer = core; } virtual ~CACKeyInstance() {} - virtual void HandleMessageThread(pp::VarDictionary *message) { + virtual void HandleMessageThread(pp::VarDictionary *message, pp::Var *messagePlain) { cackey_chrome_returnType signRet; char *pinPrompt = NULL; const char *pin; const char *smartcardManagerAppId = NULL; unsigned char buffer[8192]; @@ -39,11 +39,11 @@ struct cackey_certificate *certificates, incomingCertificateCACKey; pp::VarDictionary *reply; pp::VarArray certificatesPPArray; pp::VarArrayBuffer *certificateContents, *incomingCertificateContents, *incomingData, *outgoingData; pp::Var command; - const pp::Var *messageAsVar = NULL, *outgoingDataAsVar = NULL; + const pp::Var *outgoingDataAsVar = NULL; int numCertificates, i; unsigned long outgoingDataLength; /* * Extract the command @@ -135,27 +135,21 @@ delete outgoingData; reply->Set("status", "success"); reply->Set("signedData", outgoingDataAsVar); - delete outgoingDataAsVar; - break; case CACKEY_CHROME_ERROR: reply->Set("status", "error"); reply->Set("error", "Unable to sign data"); break; case CACKEY_CHROME_NEEDLOGIN: case CACKEY_CHROME_NEEDPROTECTEDLOGIN: - messageAsVar = new pp::Var(message->pp_var()); - reply->Set("status", "retry"); - reply->Set("originalrequest", messageAsVar); + reply->Set("originalrequest", *messagePlain); reply->Set("pinprompt", pinPrompt); - delete messageAsVar; - break; } if (pinPrompt != NULL) { free(pinPrompt); @@ -185,16 +179,23 @@ PostMessage(*reply); delete reply; delete message; + + delete messagePlain; + + if (outgoingDataAsVar) { + delete outgoingDataAsVar; + } return; } virtual void HandleMessage(const pp::Var& messagePlain) { pp::VarDictionary *message; + pp::Var *messagePlainCopy; pp::Var target; /* * The incoming message must be a dictionary */ @@ -244,11 +245,12 @@ } /* * Process the request in another thread */ - std::thread(&CACKeyInstance::HandleMessageThread, this, message).detach(); + messagePlainCopy = new pp::Var(messagePlain); + std::thread(&CACKeyInstance::HandleMessageThread, this, message, messagePlainCopy).detach(); return; } };