1 个文件变更+1-1
@@ -118,6 +118,7 @@ int32_t AddBuffToZip(const void *buf, uint32_t size, const char *nameInZip, cons
118 118 
119int32_t AddFileContextToZip(int32_t fd, const char *nameInZip, const char *zipName)119int32_t AddFileContextToZip(int32_t fd, const char *nameInZip, const char *zipName)
120{120{
121+ auto buf = std::make_unique<char[]>(ZIP_BUFF_SIZE);
121 zipFile zf = zipOpen64(zipName, APPEND_STATUS_ADDINZIP);122 zipFile zf = zipOpen64(zipName, APPEND_STATUS_ADDINZIP);
122 if (zf == nullptr) {123 if (zf == nullptr) {
123 DLP_LOG_ERROR(LABEL, "AddFileContextToZip fail err %{public}d, zipName %{public}s",124 DLP_LOG_ERROR(LABEL, "AddFileContextToZip fail err %{public}d, zipName %{public}s",
@@ -141,7 +142,6 @@ int32_t AddFileContextToZip(int32_t fd, const char *nameInZip, const char *zipNa
141 }142 }
142 int32_t readLen;143 int32_t readLen;
143 int32_t res = DLP_ZIP_OK;144 int32_t res = DLP_ZIP_OK;
144- auto buf = std::make_unique<char[]>(ZIP_BUFF_SIZE);
145 while ((readLen = read(fd, buf.get(), ZIP_BUFF_SIZE)) > 0) {145 while ((readLen = read(fd, buf.get(), ZIP_BUFF_SIZE)) > 0) {
146 err = zipWriteInFileInZip (zf, buf.get(), static_cast<unsigned>(readLen));146 err = zipWriteInFileInZip (zf, buf.get(), static_cast<unsigned>(readLen));
147 if (err != ZIP_OK) {147 if (err != ZIP_OK) {