Merge pull request #364 from mykmelez/read-on-closed-socket

return -1 early when Protocol.read0 called on closed socket
This commit is contained in:
Marco 2014-09-29 18:12:13 -07:00
Родитель a10b4e3c37 d782fd9700
Коммит b9b1520e88
1 изменённых файлов: 5 добавлений и 0 удалений

Просмотреть файл

@ -77,6 +77,11 @@ Native["com/sun/midp/io/j2me/socket/Protocol.available0.()I"] = function(ctx, st
Native["com/sun/midp/io/j2me/socket/Protocol.read0.([BII)I"] = function(ctx, stack) { Native["com/sun/midp/io/j2me/socket/Protocol.read0.([BII)I"] = function(ctx, stack) {
var length = stack.pop(), offset = stack.pop(), data = stack.pop(), _this = stack.pop(); var length = stack.pop(), offset = stack.pop(), data = stack.pop(), _this = stack.pop();
if (_this.socket.readyState == "closed") {
stack.push(-1);
return;
}
function copyData() { function copyData() {
var toRead = (length < _this.data.byteLength) ? length : _this.data.byteLength; var toRead = (length < _this.data.byteLength) ? length : _this.data.byteLength;