]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #50819 - cjkenn:cjkenn/div-by-zero, r=kennytm
authorkennytm <kennytm@gmail.com>
Sat, 19 May 2018 20:17:41 +0000 (04:17 +0800)
committerkennytm <kennytm@gmail.com>
Sat, 19 May 2018 20:17:41 +0000 (04:17 +0800)
Fix potential divide by zero

This should fix #50761

I had trouble reproducing with the provided code, but looking at the stack trace would indicate that this code is the likely cause. I made a number of assumptions here, because I don't have enough context on how the register size is set:

1. I assumed `rest.unit.size.bytes()` can be 0, and it's ok if it's set to 0 before this function is called
2. I assumed that if `rest.unit.size.bytes()` is 0, that we want `rest_count` to also be 0.


Trivial merge