Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

n_alloc has wrong value in buf_append function #54

Closed
srivasta opened this issue Feb 17, 2016 · 1 comment
Closed

n_alloc has wrong value in buf_append function #54

srivasta opened this issue Feb 17, 2016 · 1 comment

Comments

@srivasta
Copy link
Contributor

Hi,

This was reported by a Debian user in Bug 761250

The buf_append function will check if the current buf size needs
additional memory to append the new element(s).
n_alloc seems for how many ELEMENTS after append the new element(s),
so it is just a count number, and do not need to multiply with the
element size.

File: buf.c: http://sources.debian.net/src/flex/2.5.39-8/buf.c/#L245
241 /* May need to alloc more. /
242 if (n_elem + buf->nelts > buf->nmax) {
243
244 /
exact amount needed... /
245 n_alloc = (n_elem + buf->nelts) * buf->elt_size;
246
247 /
...plus some extra */
248 if (((n_alloc * buf->elt_size) % 512) != 0
249 && buf->elt_size < 512)
250 n_alloc +=
251 (512 -
252 ((n_alloc * buf->elt_size) % 512)) /
253 buf->elt_size;

Check line 245, n_alloc should direct equals n_elem + buf->nelts, the
additional multiply with buf->elt_size should be a mistake, because in
line 248 and below, when checking the 512 boundaries, the n_alloc will
multiply with the buf->elt_size.

manoj

@westes westes closed this as completed Feb 24, 2016
@westes
Copy link
Owner

westes commented Feb 24, 2016

Fixed in d2a67ba. Will be included in the next release.

eric-s-raymond added a commit to eric-s-raymond/flex that referenced this issue Oct 2, 2020
This cleans up some loose ends before the next big move.

westes#54 in the retargeting patch series. westes#53 slipped out unnumbered.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants