-
Notifications
You must be signed in to change notification settings - Fork 1k
fwrite(): when col.names=FALSE, produce a gzip header, avoid a leak
#6853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Previously, fwrite() emitted a raw DEFLATE stream if col.names was FALSE (and thus headerLen was zero). Decompressing such files is possible, but not trivial.
Previously, the zlib object zstrm was initialized whenever compression was enabled, at least in order to calculate the buffer size for the compressed data stream, but was only used for compression and subsequently deallocated only when there was a header with column names. Make sure to deflateEnd(&strm) even if there was no header.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6853 +/- ##
=======================================
Coverage 98.59% 98.59%
=======================================
Files 79 79
Lines 14661 14664 +3
=======================================
+ Hits 14455 14458 +3
Misses 206 206 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Generated via commit 133878a Download link for the artifact containing the test results: ↓ atime-results.zip
|
|
NB: this will be patched into 1.17.2: data.table/.dev/CRAN_Release.cmd Lines 620 to 628 in 6a8634e
|
Co-Authored-By: Michael Chirico <[email protected]>
Co-Authored-By: Michael Chirico <[email protected]>
MichaelChirico
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for getting this done!
| } | ||
| } | ||
| } | ||
| #ifndef NOZLIB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And if args.is_gzip is not true then we never call init_stream so this is actually not surprising anymore.
…leak (#6853) * fwrite(): emit gzip header even if !col.names Previously, fwrite() emitted a raw DEFLATE stream if col.names was FALSE (and thus headerLen was zero). Decompressing such files is possible, but not trivial. * Avoid a memory leak in fwrite(compress="gzip") Previously, the zlib object zstrm was initialized whenever compression was enabled, at least in order to calculate the buffer size for the compressed data stream, but was only used for compression and subsequently deallocated only when there was a header with column names. Make sure to deflateEnd(&strm) even if there was no header. * NEWS entry * comment the source of this #endif for clarity * Clean up the test file Co-Authored-By: Michael Chirico <[email protected]> * Report write() errno instead of just plain -1 Co-Authored-By: Michael Chirico <[email protected]> --------- Co-authored-by: Michael Chirico <[email protected]>

gzipheader generation was previously tied to header printing, together with some initialization (likecrc,len) and de-initialization (likedeflateEnd(&strm)). Moved it outside theheaderLenbranch.Fixes: #6852.