Skip to content

Commit

Permalink
Make sure that the overwrite in bs_context_to_binary is safe
Browse files Browse the repository at this point in the history
  • Loading branch information
jhogberg committed Feb 12, 2018
1 parent cd9b637 commit 1b3b438
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions erts/emulator/beam/bs_instrs.tab
Expand Up @@ -990,6 +990,9 @@ ctx_to_bin.execute() {
Uint hole_size;
Uint orig = mb->orig;
ErlSubBin* sb = (ErlSubBin *) boxed_val(context);
/* Since we're going to overwrite the match state with the result, an
* ErlBinMatchState must be at least as large as an ErlSubBin. */
ERTS_CT_ASSERT(sizeof(ErlSubBin) <= sizeof(ErlBinMatchState));
hole_size = 1 + header_arity(sb->thing_word) - ERL_SUB_BIN_SIZE;
sb->thing_word = HEADER_SUB_BIN;
sb->size = BYTE_OFFSET(size);
Expand Down

0 comments on commit 1b3b438

Please sign in to comment.