Guard against garbage collection in bytes (fixes #498)
This commit is contained in:
committed by
James Gray
parent
01fdbd5273
commit
91a719e11a
@@ -29,6 +29,7 @@ namespace lime {
|
||||
|
||||
unsigned char *_data;
|
||||
int _length;
|
||||
value *_root;
|
||||
value _value;
|
||||
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace lime {
|
||||
_data = 0;
|
||||
_length = 0;
|
||||
_value = 0;
|
||||
_root = 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -51,6 +52,7 @@ namespace lime {
|
||||
_data = 0;
|
||||
_length = 0;
|
||||
_value = 0;
|
||||
_root = 0;
|
||||
|
||||
Resize (size);
|
||||
|
||||
@@ -61,6 +63,11 @@ namespace lime {
|
||||
|
||||
initialize ();
|
||||
|
||||
_data = 0;
|
||||
_length = 0;
|
||||
_value = 0;
|
||||
_root = 0;
|
||||
|
||||
Set (bytes);
|
||||
|
||||
}
|
||||
@@ -73,6 +80,7 @@ namespace lime {
|
||||
_data = 0;
|
||||
_length = 0;
|
||||
_value = 0;
|
||||
_root = 0;
|
||||
|
||||
FILE_HANDLE *file = lime::fopen (path, "rb");
|
||||
|
||||
@@ -102,6 +110,11 @@ namespace lime {
|
||||
|
||||
initialize ();
|
||||
|
||||
_data = 0;
|
||||
_length = 0;
|
||||
_value = 0;
|
||||
_root = 0;
|
||||
|
||||
Set (data);
|
||||
|
||||
}
|
||||
@@ -109,11 +122,12 @@ namespace lime {
|
||||
|
||||
Bytes::~Bytes () {
|
||||
|
||||
//if (!_value && _data) {
|
||||
//
|
||||
//free (_data);
|
||||
//
|
||||
//}
|
||||
if (_root) {
|
||||
|
||||
*_root = 0;
|
||||
free_root (_root);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -146,6 +160,8 @@ namespace lime {
|
||||
if (!_value) {
|
||||
|
||||
_value = alloc_empty_object ();
|
||||
_root = alloc_root ();
|
||||
*_root = _value;
|
||||
|
||||
}
|
||||
|
||||
@@ -204,9 +220,20 @@ namespace lime {
|
||||
_data = 0;
|
||||
_value = 0;
|
||||
|
||||
if (_root) {
|
||||
|
||||
*_root = 0;
|
||||
free_root (_root);
|
||||
|
||||
}
|
||||
|
||||
_root = 0;
|
||||
|
||||
} else {
|
||||
|
||||
_value = bytes;
|
||||
_root = alloc_root ();
|
||||
*_root = _value;
|
||||
_length = val_int (val_field (bytes, id_length));
|
||||
|
||||
if (_length > 0) {
|
||||
@@ -248,6 +275,15 @@ namespace lime {
|
||||
_data = 0;
|
||||
_length = 0;
|
||||
|
||||
if (_root) {
|
||||
|
||||
*_root = 0;
|
||||
free_root (_root);
|
||||
|
||||
}
|
||||
|
||||
_root = 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user