mirror of
https://github.com/vale981/libblobpack
synced 2025-03-04 17:31:42 -05:00
blob: add offset check when closing tables and arrays
This commit is contained in:
parent
27be0c0c4b
commit
d67ed0db60
1 changed files with 2 additions and 0 deletions
2
blob.c
2
blob.c
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue