diff --git a/cocos/network/CCDownloader-apple.mm b/cocos/network/CCDownloader-apple.mm index 99fcfa3745..8d67db6d96 100644 --- a/cocos/network/CCDownloader-apple.mm +++ b/cocos/network/CCDownloader-apple.mm @@ -414,9 +414,9 @@ namespace cocos2d { namespace network { std::string errorString; const int64_t buflen = [wrapper totalBytesReceived]; - char buf[buflen]; + std::vector data((size_t)buflen); + char* buf = (char*)data.data(); [wrapper transferDataToBuffer:buf lengthOfBuffer:buflen]; - std::vector data(buf, buf + buflen); _outer->onTaskFinish(*[wrapper get], cocos2d::network::DownloadTask::ERROR_NO_ERROR,