Skip to content

Commit

Permalink
decode: fix AVAIL_BITS, independent on obj->size
Browse files Browse the repository at this point in the history
AVAIL_BITS only depends on dat
  • Loading branch information
rurban committed Jan 1, 2024
1 parent 5402e5d commit 6717bf5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/dec_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -1007,8 +1007,7 @@

// check for overflow into next object (invalid num_elems)
#define AVAIL_BITS(dat) \
(obj ? (int64_t)((obj->size * 8) - bit_position (dat) + 20) \
: (int64_t)0x0000ff00LL)
(int64_t)((dat->size * 8) - bit_position (dat))
#define TYPE_MAXELEMSIZE(type) dwg_bits_size[BITS_##type]
#define VECTOR_CHKCOUNT(nam, type, size, dat) \
if ((int64_t)(size) > AVAIL_BITS (dat) \
Expand Down
2 changes: 1 addition & 1 deletion src/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2590,7 +2590,7 @@ secondheader_private (Bit_Chain *restrict dat, Dwg_Data *restrict dwg)
Bit_Chain *str_dat = dat;
Dwg_SecondHeader *_obj = &dwg->secondheader;
// for error logging only:
Dwg_Object *obj = &(Dwg_Object){ .name = (char*)"2NDHEADER" };
Dwg_Object *obj = &(Dwg_Object){ .name = (char*)"2NDHEADER", .size = 117 };
int error = 0;
BITCODE_BL vcount;
if (!dat->chain || !dat->size)
Expand Down

0 comments on commit 6717bf5

Please sign in to comment.