diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-01-12 10:54:54 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-12 10:54:54 +0100 |
| commit | 017f046c1371758bf4363afd4384bafb583b9710 (patch) | |
| tree | 99d397e6d2a1f139466af80e08c2940e43c70c61 /src | |
| parent | 53aa8a1ad0fe12594347d68ee7f7c12e7c1a1937 (diff) | |
| parent | 0eacf2cb240606343284a2d38b0f54b6028b134d (diff) | |
| download | rust-017f046c1371758bf4363afd4384bafb583b9710.tar.gz rust-017f046c1371758bf4363afd4384bafb583b9710.zip | |
Rollup merge of #57042 - pnkfelix:issue-57038-sidestep-ice-in-fieldplacement-count, r=michaelwoerister
Don't call `FieldPlacement::count` when count is too large Sidestep ICE in `FieldPlacement::count` by not calling it when count will not fit in host's usize. (I briefly played with trying to fix this by changing `FieldPlacement::count` to return a `u64`. However, based on how `FieldPlacement` is used, it seems like this would be a largely pointless pursuit... I'm open to counter-arguments, however.) Fix #57038
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/ty/layout.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 171c53b7b20..1162bff852c 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -1842,7 +1842,11 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { return Ok(None); } } - if let FieldPlacement::Array { .. } = layout.fields { + if let FieldPlacement::Array { count: original_64_bit_count, .. } = layout.fields { + // rust-lang/rust#57038: avoid ICE within FieldPlacement::count when count too big + if original_64_bit_count > usize::max_value() as u64 { + return Err(LayoutError::SizeOverflow(layout.ty)); + } if layout.fields.count() > 0 { return self.find_niche(layout.field(self, 0)?); } else { |
