Skip to content

Commit

Permalink
Fixes #4060 (#4068)
Browse files Browse the repository at this point in the history
Extra byte evaluated to truthy with an empty slice. Added size check which fixes the gzip bug.
  • Loading branch information
crisward authored and Ary Borenszweig committed Mar 1, 2017
1 parent f58fd86 commit 2e61cca
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/gzip/header.cr
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Gzip::Header

# flg
flg = Flg::None
flg |= Flg::EXTRA if @extra
flg |= Flg::EXTRA unless @extra.empty?
flg |= Flg::NAME if @name
flg |= Flg::COMMENT if @comment
io.write_byte flg.value
Expand All @@ -85,9 +85,9 @@ class Gzip::Header
# os
io.write_byte os

if extra = @extra
io.write_byte extra.size.to_u8
io.write(extra)
unless @extra.empty?
io.write_byte @extra.size.to_u8
io.write(@extra)
end

if name = @name
Expand Down

0 comments on commit 2e61cca

Please sign in to comment.