diff options
author | Björn-Egil Dahlberg <[email protected]> | 2014-01-20 09:38:55 +0100 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2014-01-20 09:38:55 +0100 |
commit | 967d476a31391bf01e2cc0e37435874c369c89dc (patch) | |
tree | 254e23862bb08aaf3cea3cb17db67c2628e31276 | |
parent | 65a580abaa082019b7f21df719f0b29b1eee3577 (diff) | |
parent | 71e6fe5bcbd7b2b98dfa159db34ee1fe14823a56 (diff) | |
download | otp-967d476a31391bf01e2cc0e37435874c369c89dc.tar.gz otp-967d476a31391bf01e2cc0e37435874c369c89dc.tar.bz2 otp-967d476a31391bf01e2cc0e37435874c369c89dc.zip |
Merge branch 'egil/fix-bs_get_integer/OTP-11581'
* egil/fix-bs_get_integer/OTP-11581:
erts: Fix bs_get_integer instruction
-rw-r--r-- | erts/emulator/beam/beam_emu.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/erts/emulator/beam/beam_emu.c b/erts/emulator/beam/beam_emu.c index 78ab6fa30f..592cfe273f 100644 --- a/erts/emulator/beam/beam_emu.c +++ b/erts/emulator/beam/beam_emu.c @@ -4326,7 +4326,19 @@ void process_main(void) flags = Arg(2); BsGetFieldSize(tmp_arg2, (flags >> 3), ClauseFail(), size); if (size >= SMALL_BITS) { - Uint wordsneeded = 1+WSIZE(NBYTES((Uint) size)); + Uint wordsneeded; + /* check bits size before potential gc. + * We do not want a gc and then realize we don't need + * the allocated space (i.e. if the op fails) + * + * remember to reacquire the matchbuffer after gc. + */ + + mb = ms_matchbuffer(tmp_arg1); + if (mb->size - mb->offset < size) { + ClauseFail(); + } + wordsneeded = 1+WSIZE(NBYTES((Uint) size)); TestHeapPreserve(wordsneeded, Arg(1), tmp_arg1); } mb = ms_matchbuffer(tmp_arg1); |