{"action":"opened","issue":{"url":"https://api.github.com/repos/openfl/openfl/issues/1013","labels_url":"https://api.github.com/repos/openfl/openfl/issues/1013/labels{/name}","comments_url":"https://api.github.com/repos/openfl/openfl/issues/1013/comments","events_url":"https://api.github.com/repos/openfl/openfl/issues/1013/events","html_url":"https://github.com/openfl/openfl/issues/1013","id":127262362,"number":1013,"title":"ByteArray's BytesData has invalid size in some cases","user":{"login":"modjke","id":2504184,"avatar_url":"https://avatars.githubusercontent.com/u/2504184?v=3","gravatar_id":"","url":"https://api.github.com/users/modjke","html_url":"https://github.com/modjke","followers_url":"https://api.github.com/users/modjke/followers","following_url":"https://api.github.com/users/modjke/following{/other_user}","gists_url":"https://api.github.com/users/modjke/gists{/gist_id}","starred_url":"https://api.github.com/users/modjke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/modjke/subscriptions","organizations_url":"https://api.github.com/users/modjke/orgs","repos_url":"https://api.github.com/users/modjke/repos","events_url":"https://api.github.com/users/modjke/events{/privacy}","received_events_url":"https://api.github.com/users/modjke/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-18T16:30:54Z","updated_at":"2016-01-18T16:30:54Z","closed_at":null,"body":"Haxe 3.2.1\r\nLime 2.8.3\r\nOpenFL 3.5.3\r\n\r\n\tvar bytes = Bytes.alloc(100); //will copy from it\r\n\tbytes.fill(0, 100, 0);\r\n\t\t\r\n\tvar byteArray = new ByteArray();\r\n\t(bytes:ByteArray).readBytes(byteArray, 0, 100);\r\n\t\t\r\n\ttrace(byteArray.length); //100 - correct\r\n\ttrace((byteArray:Bytes).getData().length); //151 - wrong\r\n\r\nSo after reading the first 100 bytes via readBytes to a ByteArray with no length set (no parameters passed to constructor), it's internal BytesData (getData()) has invalid length while byteArray itself has proper length.\r\n\r\nSetting ByteArray's length via constructor fixes the issue for me\r\n\r\n\tvar byteArray = new ByteArray(100);\r\n\t(bytes:ByteArray).readBytes(byteArray, 0, 100);\r\n\t\t\r\n\ttrace(byteArray.length); //100 - correct\r\n\ttrace((byteArray:Bytes).getData().length); //100 - correct"}}