Commit 83ac5389 authored by Hanspeter Portner's avatar Hanspeter Portner

add checks for string size before printing.

parent 508b4167
......@@ -246,6 +246,8 @@ _atom_stringify(UI *ui, char *ptr, char *end, int newline, const LV2_Atom *atom)
else if(atom->type == ui->forge.String)
{
char *str = LV2_ATOM_CONTENTS(LV2_Atom_String, atom);
if(atom->size == 0)
str = "";
// truncate
char tmp[4] = {'\0'};
......@@ -264,6 +266,8 @@ _atom_stringify(UI *ui, char *ptr, char *end, int newline, const LV2_Atom *atom)
else if(atom->type == ui->forge.Path)
{
char *str = LV2_ATOM_CONTENTS(LV2_Atom_String, atom);
if(atom->size == 0)
str = "";
// truncate
char tmp[4] = {'\0'};
......@@ -284,6 +288,8 @@ _atom_stringify(UI *ui, char *ptr, char *end, int newline, const LV2_Atom *atom)
const LV2_Atom_Literal *atom_lit = (const LV2_Atom_Literal *)atom;
char *str = LV2_ATOM_CONTENTS(LV2_Atom_Literal, atom);
if(atom->size == sizeof(LV2_Atom_Literal_Body))
str = "";
const char *datatype = _hash_get(ui, atom_lit->body.datatype);
const char *lang = _hash_get(ui, atom_lit->body.lang);
......@@ -316,6 +322,8 @@ _atom_stringify(UI *ui, char *ptr, char *end, int newline, const LV2_Atom *atom)
else if(atom->type == ui->forge.URI)
{
char *str = LV2_ATOM_CONTENTS(LV2_Atom_String, atom);
if(atom->size == 0)
str = "";
LV2_URID urid = ui->map->map(ui->map->handle, str); //TODO add hashing
// truncate
......
......@@ -159,7 +159,10 @@ _atom_stringify(UI *ui, char *ptr, char *end, const LV2_Atom *atom)
{
if(itm->type == ui->forge.String)
{
sprintf(ptr, TYPE(" s:", "%s"), LV2_ATOM_BODY_CONST(itm));
const char *str = LV2_ATOM_BODY_CONST(itm);
if(itm->size == 0)
str = "";
sprintf(ptr, TYPE(" s:", "%s"), str);
ptr += strlen(ptr);
}
break;
......
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