A fork of https://github.com/crosspoint-reader/crosspoint-reader
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: two small memory leaks (#1628)

## Summary

* **What is the goal of this PR?**

Fix two issues pointed out by `CodeRabbit` in #1433:

1. Free the output buffer in `readFileToMemory` on early error paths
(prevents memory leaks).
2. Check `out.write()` return value in the STORED path (same as in the
DEFLATED path).

I can confirm both issues were real (not hallucinations). Both fixes are
minimal — no behavior change on success.

---

### AI Usage

Did you use AI tools to help write this code? _**< NO >**_

authored by

Uri Tauber and committed by
GitHub
104f391a b3b43bb3

+7 -1
+7 -1
lib/ZipFile/ZipFile.cpp
··· 400 400 const auto deflatedData = static_cast<uint8_t*>(malloc(deflatedDataSize)); 401 401 if (deflatedData == nullptr) { 402 402 LOG_ERR("ZIP", "Failed to allocate memory for decompression buffer"); 403 + free(data); 403 404 return nullptr; 404 405 } 405 406 ··· 430 431 // Continue out of block with data set 431 432 } else { 432 433 LOG_ERR("ZIP", "Unsupported compression method"); 434 + free(data); 433 435 return nullptr; 434 436 } 435 437 ··· 469 471 return false; 470 472 } 471 473 472 - out.write(buffer, dataRead); 474 + if (out.write(buffer, dataRead) != dataRead) { 475 + LOG_ERR("ZIP", "Failed to write all output bytes to stream"); 476 + free(buffer); 477 + return false; 478 + } 473 479 remaining -= dataRead; 474 480 } 475 481