Commit 07d915dc authored by Hanspeter Portner's avatar Hanspeter Portner

web_ui: add missing checks.

* add missing checks
* use libwebsockets in audo Rx memory allocation
parent 7fba9738
Pipeline #4236511 passed with stages
in 17 minutes and 52 seconds
......@@ -300,11 +300,14 @@ _jsatom_encode_midi(jsatom_t *jsatom, uint32_t size, LV2_URID type, const void *
//cJSON_AddItemToObject(obj, JSON_LD_TYPE, _jsatom_encode_types(LV2_MIDI__MidiEvent, NS_XSD"hexBinary", NULL));
cJSON_AddItemToObject(obj, JSON_LD_TYPE, _jsatom_encode_types(LV2_MIDI__MidiEvent, NULL));
char *hex = malloc(size*2+1);
const uint8_t *m = body;
for(unsigned i = 0; i < size; i++)
sprintf(&hex[i*2], "%02"PRIx8, m[i]);
cJSON_AddItemToObject(obj, JSON_LD_VALUE, cJSON_CreateString(hex));
free(hex);
if(hex)
{
const uint8_t *m = body;
for(unsigned i = 0; i < size; i++)
sprintf(&hex[i*2], "%02"PRIx8, m[i]);
cJSON_AddItemToObject(obj, JSON_LD_VALUE, cJSON_CreateString(hex));
free(hex);
}
return obj;
}
......@@ -363,10 +366,9 @@ _jsatom_encode_raw(jsatom_t *jsatom, uint32_t size, LV2_URID type, const void *b
static inline cJSON *
jsatom_encode(jsatom_t *jsatom, uint32_t size, LV2_URID type, const void *body)
{
cJSON *obj = _jsatom_encode_raw(jsatom, size, type, body);
cJSON *arr = cJSON_CreateArray();
if(obj)
cJSON_AddItemToArray(arr, obj);
cJSON *obj = _jsatom_encode_raw(jsatom, size, type, body);
cJSON_AddItemToArray(arr, obj);
return arr;
}
......
......@@ -81,7 +81,6 @@ struct _pmap_t {
};
struct _client_t {
client_t *next;
cJSON *root;
};
......@@ -448,13 +447,15 @@ static const struct lws_protocols protocols [] = {
.name = "http-only",
.callback = callback_http,
.per_session_data_size = 0,
.rx_buffer_size = BUF_SIZE,
//.rx_buffer_size = BUF_SIZE,
.rx_buffer_size = 0
},
[PROTOCOL_LV2] = {
.name = "lv2-protocol",
.callback = callback_lv2,
.per_session_data_size = sizeof(client_t),
.rx_buffer_size = BUF_SIZE,
//.rx_buffer_size = BUF_SIZE
.rx_buffer_size = 0
},
{ .name = NULL, .callback = NULL, .per_session_data_size = 0, .rx_buffer_size = 0 }
};
......@@ -467,6 +468,7 @@ _moony_message_forge(ui_t *ui, LV2_URID key,
ser->offset = 0;
lv2_atom_forge_set_sink(&ui->forge, _sink_ui, _deref_ui, ser);
memset(ser->buf, 0x0, sizeof(LV2_Atom));
if(_moony_patch(&ui->uris.patch, &ui->forge, key, str, size))
{
......@@ -581,6 +583,7 @@ _moony_send(ui_t *ui, uint32_t idx, uint32_t size, uint32_t prot, const void *bu
ser->offset = 0;
lv2_atom_forge_set_sink(&ui->forge, _sink_ui, _deref_ui, ser);
memset(ser->buf, 0x0, sizeof(LV2_Atom));
LV2_Atom_Forge_Frame frame;
lv2_atom_forge_object(&ui->forge, &frame, 0, ui->uris.ui_port_notification);
......@@ -732,10 +735,12 @@ _moony_cb(ui_t *ui, const char *json)
ser->offset = 0;
lv2_atom_forge_set_sink(&ui->forge, _sink_ui, _deref_ui, ser);
memset(ser->buf, 0x0, sizeof(LV2_Atom));
if(!jsatom_decode(&ui->jsatom, &ui->forge, root))
return;
const LV2_Atom_Forge_Ref ref = jsatom_decode(&ui->jsatom, &ui->forge, root);
cJSON_Delete(root);
if(!ref)
return;
const LV2_Atom_Object *obj = (const LV2_Atom_Object *)ser->buf;
if( !lv2_atom_forge_is_object_type(&ui->forge, obj->atom.type)
......
......@@ -759,7 +759,7 @@ function lv2_success(data) {
jsonld.compact(data, context, options, function(err, compacted, ctx) {
if(err)
return;
if(node_is_a(compacted, UI.portNotification)) {
var symbol = compacted[LV2.symbol][RDF.value];
var prot = compacted[UI.protocol][RDF.id];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment