@@ -48,17 +48,15 @@ typedef struct
4848void P2PParse_List (LPCXSTR lpszMsgBuffer, int nMsgLen, list<P2PFILE_INFO>* pStl_ListFile)
4949{
5050 Json::Value st_JsonRoot;
51- Json::CharReaderBuilder st_JsonBuild;
52- Json::CharReader* pSt_JsonReader (st_JsonBuild.newCharReader ());
53-
5451 JSONCPP_STRING st_JsonError;
52+ Json::CharReaderBuilder st_JsonBuilder;
53+
54+ std::unique_ptr<Json::CharReader> const pSt_JsonReader (st_JsonBuilder.newCharReader ());
5555 // 解析JSON
5656 if (!pSt_JsonReader->parse (lpszMsgBuffer, lpszMsgBuffer + nMsgLen, &st_JsonRoot, &st_JsonError))
5757 {
5858 return ;
5959 }
60- delete pSt_JsonReader;
61- pSt_JsonReader = NULL ;
6260
6361 int nCount = st_JsonRoot[" Count" ].asInt ();
6462 Json::Value st_JsonArray = st_JsonRoot[" List" ];
@@ -174,7 +172,7 @@ int main()
174172 st_JsonRoot[" nMode" ] = 1 ; // 使用P2P下载
175173 st_JsonRoot[" lpszBuckKey" ] = " storagekey2" ;
176174 // st_JsonRoot["lpszFileName"] = "qq.exe";
177- st_JsonRoot[" lpszFileHash" ] = " 781E5E245D69B566979B86E28D23F2C7 " ;
175+ st_JsonRoot[" lpszFileHash" ] = " E50A10E2C9414F0397FF85393A6F68C9 " ;
178176
179177 if (!APIClient_Http_Request (_X (" POST" ), lpszUrl, st_JsonRoot.toStyledString ().c_str (), &nHTTPCode, &ptszMsgBody, &nBodyLen))
180178 {
@@ -185,6 +183,10 @@ int main()
185183 list<P2PFILE_INFO> stl_ListFile;
186184 P2PParse_List (ptszMsgBody, nBodyLen, &stl_ListFile);
187185
186+ if (stl_ListFile.empty ())
187+ {
188+ return -1 ;
189+ }
188190 // 创建稀疏文件(一个空白的文件)
189191 if (!SystemApi_File_CreateSparseFile (lpszFile, stl_ListFile.front ().st_ProtocolFile .nFileSize ))
190192 {
0 commit comments