Skip to content

Commit 763d702

Browse files
committed
encode: more wrong bit_chain_alloc usages
1 parent 0e9dc5e commit 763d702

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/encode.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,10 +1695,7 @@ copy_R2004_section (Bit_Chain *restrict dat, BITCODE_RC *restrict decomp,
16951695
uint32_t decomp_data_size, uint32_t *comp_data_size)
16961696
{
16971697
if (dat->size < dat->byte + decomp_data_size)
1698-
{
1699-
dat->size = dat->byte + decomp_data_size;
1700-
bit_chain_alloc (dat);
1701-
}
1698+
bit_chain_alloc_size (dat, decomp_data_size);
17021699
assert (!dat->bit);
17031700
memcpy (&dat->chain[dat->byte], decomp, decomp_data_size);
17041701
dat->byte += decomp_data_size;
@@ -2948,8 +2945,7 @@ encode_objects_handles (Dwg_Data *restrict dwg, Bit_Chain *restrict dat,
29482945
if (end_address > dat->size)
29492946
{
29502947
assert (obj->size < DWG_MAX_OBJSIZE);
2951-
dat->size = end_address;
2952-
bit_chain_alloc (dat);
2948+
bit_chain_alloc_size (dat, end_address - dat->size);
29532949
}
29542950
}
29552951

@@ -3037,8 +3033,6 @@ encode_objects_handles (Dwg_Data *restrict dwg, Bit_Chain *restrict dat,
30373033
assert (pvzadr);
30383034
}
30393035
#endif
3040-
if (pvzadr + 1 >= dat->size)
3041-
bit_chain_alloc (dat);
30423036
#ifdef ENCODE_PATCH_RSSIZE
30433037
encode_patch_RSsize (dat, pvzadr);
30443038
#else
@@ -3968,8 +3962,9 @@ dwg_encode (Dwg_Data *restrict dwg, Bit_Chain *restrict dat)
39683962
SECTION_SYSTEM_MAP + 1, sizeof (Dwg_Section_Info));
39693963
}
39703964
}
3971-
/* End of the file */
3972-
dat->size = dat->byte;
3965+
else
3966+
/* End of the file */
3967+
dat->size = dat->byte;
39733968

39743969
SINCE (R_2004a)
39753970
{
@@ -4439,10 +4434,7 @@ dwg_encode (Dwg_Data *restrict dwg, Bit_Chain *restrict dat)
44394434
assert (section_address);
44404435
dat->byte = section_address;
44414436
if (dat->byte + size >= dat->size)
4442-
{
4443-
dat->size = dat->byte + size;
4444-
bit_chain_alloc (dat);
4445-
}
4437+
bit_chain_alloc_size (dat, size);
44464438
LOG_HANDLE ("@%" PRIuSIZE ".0\n", dat->byte);
44474439
for (i = 0; i < ARRAY_SIZE (stream_order); i++)
44484440
{

0 commit comments

Comments
 (0)