Bytes fixes

This commit is contained in:
Joshua Granick
2018-06-26 10:45:53 -07:00
parent 9eadab5487
commit 613986bb0f

View File

@@ -229,7 +229,7 @@ namespace lime {
value Bytes::Value (value bytes) {
if (val_is_null (bytes)) {
if (val_is_null (bytes) || !b) {
return alloc_null ();
@@ -243,7 +243,10 @@ namespace lime {
if (val_is_null (_buffer) || (char*)b != buffer_data (val_to_buffer (_buffer))) {
alloc_field (bytes, id_b, buffer_val (alloc_buffer ((const char*)b)));
buffer bufferValue = alloc_buffer_len (length);
_buffer = buffer_val (bufferValue);
memcpy ((unsigned char*)buffer_data (bufferValue), b, length);
alloc_field (bytes, id_b, _buffer);
}
@@ -261,6 +264,9 @@ namespace lime {
}
free (b);
b = NULL;
return bytes;
}