blob: add offset check when closing tables and arrays

This commit is contained in:
Martin Schröder 2016-03-04 14:07:35 +01:00
parent 27be0c0c4b
commit d67ed0db60

2
blob.c
View file

@ -213,6 +213,7 @@ blob_offset_t blob_open_array(struct blob *buf){
}
void blob_close_array(struct blob *buf, blob_offset_t offset){
if((unsigned long)offset > blob_size(buf)) return;
struct blob_field *attr = blob_offset_to_attr(buf, offset);
int len = (buf->buf + blob_field_raw_len(blob_head(buf))) - (void*)attr;
blob_field_set_raw_len(attr, len);
@ -224,6 +225,7 @@ blob_offset_t blob_open_table(struct blob *buf){
}
void blob_close_table(struct blob *buf, blob_offset_t offset){
if((unsigned long)offset > blob_size(buf)) return;
struct blob_field *attr = blob_offset_to_attr(buf, offset);
int len = (buf->buf + blob_field_raw_len(blob_head(buf))) - (void*)attr;
blob_field_set_raw_len(attr, len);