File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424 before starting web server
2525 - This feels a bit nicer because there's no need to reference count a type
2626 which must live for the entire program anyways.
27+ - Don't potentially try to create a string with ` usize::MAX ` capacity when
28+ displaying a file
29+ - Pretty sure that since all relevant (>= 32 bits) platforms can fit 1048576
30+ in a usize, that this bug would never actually happen. But it shouldn't
31+ exist in the code.
2732
2833## [ v0.2.12] - 2024-11-04
2934
Original file line number Diff line number Diff line change @@ -140,7 +140,9 @@ pub async fn display(
140140 . syntax_set
141141 . find_syntax_by_extension ( extension)
142142 . unwrap_or_else ( || state. syntax_set . find_syntax_plain_text ( ) ) ;
143- let mut contents = String :: with_capacity ( size. try_into ( ) . unwrap_or ( usize:: MAX ) ) ;
143+ // should be alright to assume that 1,048,576 fits in usize on relevant
144+ // platforms
145+ let mut contents = String :: with_capacity ( size as usize ) ;
144146 upload
145147 . file
146148 . read_to_string ( & mut contents)
You can’t perform that action at this time.
0 commit comments