version 0.3.21
[fms.git] / src / freenet / introductionpuzzleinserter.cpp
index 60f7bb6..5ccb25e 100644 (file)
@@ -87,8 +87,7 @@ void IntroductionPuzzleInserter::GenerateCaptcha(std::string &encodeddata, std::
        }\r
        m_log->trace("IntroductionPuzzleInserter::GenerateCaptcha using alternate captcha generator");\r
 #else\r
-       SimpleCaptcha captcha;\r
-       cap=&captcha;\r
+       cap=new SimpleCaptcha();\r
 #endif\r
        std::vector<unsigned char> puzzle;\r
        std::vector<unsigned char> puzzlesolution;\r
@@ -179,18 +178,18 @@ void IntroductionPuzzleInserter::Initialize()
 const bool IntroductionPuzzleInserter::StartInsert(const long &localidentityid)\r
 {\r
        Poco::DateTime now;\r
-       std::string idstring;\r
+       std::string idstring="";\r
        long index=0;\r
-       std::string indexstr;\r
+       std::string indexstr="";\r
        Poco::UUIDGenerator uuidgen;\r
        Poco::UUID uuid;\r
-       std::string messagebase;\r
+       std::string messagebase="";\r
        IntroductionPuzzleXML xml;\r
-       std::string encodedpuzzle;\r
-       std::string solutionstring;\r
+       std::string encodedpuzzle="";\r
+       std::string solutionstring="";\r
        FCPMessage message;\r
-       std::string xmldata;\r
-       std::string xmldatasizestr;\r
+       std::string xmldata="";\r
+       std::string xmldatasizestr="";\r
        std::string privatekey="";\r
        std::string publickey="";\r
        std::string keypart="";\r
@@ -228,6 +227,11 @@ const bool IntroductionPuzzleInserter::StartInsert(const long &localidentityid)
                Option::Instance()->Get("MessageBase",messagebase);\r
 \r
                GenerateCaptcha(encodedpuzzle,solutionstring);\r
+               if(encodedpuzzle.size()==0)\r
+               {\r
+                       m_log->fatal("IntroductionPuzzleInserter::StartInsert could not create introduction puzzle");\r
+                       return false;\r
+               }\r
 \r
                try\r
                {\r