cnvstowによるBOFで音もなく落ちるHSP君

#include "HSP3utf.as" #include "kernel32 […]

#include "HSP3utf.as" #include "kernel32 […]

#include "HSP3utf.as"
#include "kernel32.as"
#define WM_MOUSEMOVE                    0x0200

	screen 0, 1600, 900
	font "メイリオ", 13
	randomize
	
	oncmd gosub *WM_MOUSEMOVE_, WM_MOUSEMOVE
	count = 0
	stop

	/*
		マウルカーソルを画面上で動かすとWM_MOUSEMOVEを捕捉して以下のサブルーチンが実行されます
		しばらく動かしてるとスッ…とプロセスが落ちるよ!
		艦これ一覧めいかー改二はこのバグに悩まされていたんDA★
	*/


*WM_MOUSEMOVE_


	//アルファベット、ひらがなカタカナ混合の64~128文字の文字列を作成し変数に代入する
	utf8 =  makeRandomString()
	//UTF-16に変換したときの文字数を取得する
	wideLen = MultiByteToWideChar(65001, 0, varptr(utf8), strlen(utf8), 0, 0)
	//UTF-16の文字列は1文字2Byteなので終端文字まで含めたバッファを確保する(指定はByte)
	sdim wide, wideLen*2+2

	//画面に作成した文字列を表示させる
	mes utf8
	//必要な領域をちゃんと確保したバッファにHSPの標準命令でUTF-8→UTF-16に変換する
	cnvstow wide, utf8
	
	if (count\50==0):cls
	count++
	
return

#module

#defcfunc makeRandomString

	sdim output, 1024
	sdim t
	outIdx = 0
	
	repeat 64+rnd(64)
		switch rnd(5)
			case 0
				t = "!"
				poke t, 0, peek(t,0)+rnd(93)
				poke output, outIdx, peek(t, 0)
				outIdx++
				swbreak
			
			case 1
				t = "ぁ"
				poke t, 2, peek(t,2)+rnd(63)
				wpoke output, outIdx, wpeek(t, 0)
				poke output, outIdx+2, peek(t, 2)
				outIdx += 3
				swbreak

			case 2
				t = "む"
				poke t, 2, peek(t,2)+rnd(23)
				wpoke output, outIdx, wpeek(t, 0)
				poke output, outIdx+2, peek(t, 2)
				outIdx += 3
				swbreak

			case 3
				t = "ァ"
				poke t, 2, peek(t,2)+rnd(31)
				wpoke output, outIdx, wpeek(t, 0)
				poke output, outIdx+2, peek(t, 2)
				outIdx += 3
				swbreak

			case 4
				t = "ダ"
				poke t, 2, peek(t,2)+rnd(59)
				wpoke output, outIdx, wpeek(t, 0)
				poke output, outIdx+2, peek(t, 2)
				outIdx += 3
				swbreak
		swend
	loop

return output

#global