Bug 883766 - JavaScript Warning: "reference to undefined property ret.value" {file: "resource://gre/modules/wifi_worker.js" line: 71} r=mrbkap

This commit is contained in:
Vincent Chang 2013-06-20 18:43:15 +08:00
parent 71bf559fdc
commit e5404b3ebe

View File

@ -68,8 +68,14 @@ self.onmessage = function(e) {
break;
case "wait_for_event":
var ret = libhardware_legacy.wait_for_event(cbuf, 4096);
var event = cbuf.readString().substr(0, ret.value);
postMessage({ id: id, event: event });
// Check the array index.
if (ret > 0 && ret < 4096) {
// Make sure the string buffer is null terminated.
cbuf[ret] = 0;
// Use readStringReplaceMalformed() to handle non-UTF8-encoded string.
var event = cbuf.readStringReplaceMalformed();
postMessage({ id: id, event: event });
}
break;
case "ifc_reset_connections":
var ret = libnetutils.ifc_reset_connections(data.ifname,