Skip to content

Fix Columnar sort priority crash after mutation#274

Open
GabrielNagy wants to merge 1 commit intomime-types:mainfrom
GabrielNagy:fix-columnar-sort-priority-after-clear
Open

Fix Columnar sort priority crash after mutation#274
GabrielNagy wants to merge 1 commit intomime-types:mainfrom
GabrielNagy:fix-columnar-sort-priority-after-clear

Conversation

@GabrielNagy
Copy link
Copy Markdown

When a setter like extensions= clears @__sort_priority and the container is not fully loaded, Columnar#update_sort_priority reads bits from nil instead of recomputing. Fall back to super in that case.

Short repro script:

MIME::Types["text/plain"].first.add_extensions("json")
MIME::Types.type_for("test.json")
~/.gem/ruby/3.3.6/gems/mime-types-3.7.0/lib/mime/types.rb:155:in `sort': comparison of MIME::Type::Columnar with MIME::Type::Columnar failed (ArgumentError)

When a setter like extensions= clears @__sort_priority and the
container is not fully loaded, Columnar#update_sort_priority reads
bits from nil instead of recomputing. Fall back to super in that case.

Signed-off-by: Gabriel Nagy <gabrielnagy@me.com>
@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 88.743% (-0.3%) from 89.035%
when pulling 31a39f6 on GabrielNagy:fix-columnar-sort-priority-after-clear
into 7de6c8d on mime-types:main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants