1
0
mirror of https://github.com/KubaPro010/fm-dx-webserver.git synced 2026-02-26 22:13:53 +01:00

Fix empty RT exception

This commit is contained in:
Konrad Kosmatka
2024-01-28 20:26:58 +01:00
parent 457e756569
commit 5c421f2ea1

View File

@@ -168,17 +168,23 @@ rdsparser.register_ptyn(rds, callbacks.ptyn);
rdsparser.register_ct(rds, callbacks.ct);
const decode_unicode = function(string) {
let content = rdsparser.string_get_content(string);
let length = rdsparser.string_get_length(string);
let array = koffi.decode(content, koffi.array(unicode_type, length));
return String.fromCodePoint.apply(String, array);
if (length) {
let content = rdsparser.string_get_content(string);
let array = koffi.decode(content, koffi.array(unicode_type, length));
return String.fromCodePoint.apply(String, array);
}
return '';
};
const decode_errors = function(string) {
let errors = rdsparser.string_get_errors(string);
let length = rdsparser.string_get_length(string);
let array = koffi.decode(errors, koffi.array('uint8_t', length));
return Uint8Array.from(array).toString();
if (length) {
let errors = rdsparser.string_get_errors(string);
let array = koffi.decode(errors, koffi.array('uint8_t', length));
return Uint8Array.from(array).toString();
}
return '';
};
const updateInterval = 75;
@@ -334,4 +340,4 @@ function showOnlineUsers(currentUsers) {
module.exports = {
handleData, showOnlineUsers, dataToSend
};
};