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.
--- 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 <udis86.h>
-#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 );