Fixed string serialization
This commit is contained in:
parent
7c2d741759
commit
5a9f1546db
|
@ -268,10 +268,10 @@ Variable * variable_new_deserialize_type(VariableType type, size_t * size,
|
||||||
case VT_FLOAT:
|
case VT_FLOAT:
|
||||||
case VT_DOUBLE:
|
case VT_DOUBLE:
|
||||||
case VT_STRING:
|
case VT_STRING:
|
||||||
for(s = 0; s < *size;)
|
for(s = 0; s < *size; s++)
|
||||||
if(data[s++] != '\0')
|
if(data[s] != '\0')
|
||||||
continue;
|
continue;
|
||||||
else if((p = malloc(s)) == NULL)
|
else if((p = malloc(++s)) == NULL)
|
||||||
{
|
{
|
||||||
error_set_code(1, "%s",
|
error_set_code(1, "%s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
@ -679,7 +679,7 @@ int variable_serialize(Variable * variable, Buffer * buffer, int type)
|
||||||
p = buffer_get_data(variable->u.buffer);
|
p = buffer_get_data(variable->u.buffer);
|
||||||
break;
|
break;
|
||||||
case VT_STRING:
|
case VT_STRING:
|
||||||
size = string_get_length(variable->u.string);
|
size = string_get_length(variable->u.string) + 1;
|
||||||
p = variable->u.string;
|
p = variable->u.string;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user