Skip to content
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

fix adding an ArchiveMember to another ZipArchive #1775

Merged
merged 1 commit into from
Dec 16, 2013

Conversation

MartinNowak
Copy link
Member

No description provided.

@MartinNowak MartinNowak restored the std_zip3 branch December 14, 2013 19:14
de._compressedData = _data[off .. off + de.compressedSize];
}
else
if (!de._compressedData.length)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: if (de._compressedData.empty) (IMO). Just ignore if you disagree.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but then I'd have to import std.range.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. I forget it's not a natural array primitive.

@monarchdodra
Copy link
Collaborator

I don't really understand what's going on here. Can anybody else review? Or @MartinNowak : Can you explain to the un-initiated?

@MartinNowak
Copy link
Member Author

This issue was introduced with #1697. It causes a RangeError if I read a ZipArchive from disk and copy one of it's ArchiveMembers to a new ZipArchive. This happens, because _compressedData is reset to _data slice from the ZipArchive, but the newly constructed ZipArchive doesn't yet have any _data.
The fix is very simple, if an archive member already has _compressedData leave it untouched and simply copy it's data to the output zip.

monarchdodra added a commit that referenced this pull request Dec 16, 2013
fix adding an ArchiveMember to another ZipArchive
@monarchdodra monarchdodra merged commit 11f3b0f into dlang:master Dec 16, 2013
@MartinNowak MartinNowak deleted the std_zip3 branch December 16, 2013 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants