Project: titanium
Issue TIMOB-23222: Windows: Ti.Codec.decodeNumber crashes when reading from buffer
The following code makes the app crash in the for-loop. When decreasing the number of loops to run the risk of getting the crash decreases. (i<200 often works, but i<2048 crashes most of the time). {code} var file = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, "data/data.bin"); Ti.API.info('File meta:' + file.size); var blob = file.read(); var length = blob.length; // Convert Ti.Blob to Ti.Buffer var stream = Ti.Stream.createStream({source:blob, mode: Ti.Stream.MODE_READ}); var buffer = Ti.createBuffer({length: length}); stream.read(buffer); Ti.API.info("file loaded. size="+buffer.length); // Read and parse the data var index = Ti.Codec.decodeNumber({source:buffer, position:0, type:Ti.Codec.TYPE_INT}); Ti.API.info('Checkpoint:'); var myArray = []; for (var i=0; i<2048; i++) { myArray.push([ Ti.Codec.decodeNumber({source:buffer, position:4+i*8+0, type:Ti.Codec.TYPE_INT}), Ti.Codec.decodeNumber({source:buffer, position:4+i*8+4, type:Ti.Codec.TYPE_INT}) ]); }; Ti.API.info('Done'); {code}
Story points: 5