# HG changeset patch # User Jan Vrany # Date 1535574739 -3600 # Node ID 7f439240d923f1999aa64ad6b25e91c1abb303f3 # Parent 704b049b9aa291e31c8daabfba3aed43f52d2d3f UDIS86: fixed crash caused by keeping `ud_t` structure on smalltalk heap ...and this the structure may move. Thisx resulted on hard-to-debug heap corruptions because `ud_t.asm_buf` is initializad to a pointer to `ud_t.asm_buf_int`. Therefore when the bytearray moved, the pointer become invalid and subsequent call to `ud_disassemble()` smashed whatever object happened to be where the bytearray were. The fix is straigtforward, use `ExternalBytes`! Sigh. diff -r 704b049b9aa2 -r 7f439240d923 udis86sx/UDIS86.st --- a/udis86sx/UDIS86.st Thu Aug 16 14:10:06 2018 +0100 +++ b/udis86sx/UDIS86.st Wed Aug 29 21:32:19 2018 +0100 @@ -43,7 +43,7 @@ #include -#define ud ((ud_t*)(&__byteArrayVal( __INST(handle) ))) +#define ud ((ud_t*)(__externalAddressVal( __INST(handle) ))) %} ! ! @@ -317,7 +317,7 @@ %{ handleSize = __MKSMALLINT( sizeof( ud_t ) ); %}. - handle := ByteArray new: handleSize. + handle := ExternalBytes unprotectedNew: handleSize. %{ ud_init( ud ); ud_set_syntax ( ud, UD_SYN_INTEL );