You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Array size: 3
==19255== Invalid read of size 8
==19255== at 0x4C2DECE: memcpy@GLIBC_2.2.5 (vg_replace_strmem.c:1021)
==19255== by 0x5E41A48: array_remove_at (in /.../reqs/lib/libcollectc.so)
==19255== ...
==19255== Address 0xb01b358 is 0 bytes after a block of size 24 alloc'd
==19255== at 0x4C29BC3: malloc (vg_replace_malloc.c:299)
==19255== by 0x5E414D4: array_new_conf (in /.../reqs/lib/libcollectc.so)
==19255== by 0x5E459FF: hashtable_get_values (in /.../reqs/lib/libcollectc.so)
==19255== ...
==19255==
Array size: 2
If I create array manually using array_new, I don't get the same issue. Looking at the source code of array_remove_at I can see there is a call to memmove (https://github.com/srdja/Collections-C/blob/master/src/array.c#L317) which I'm guessing is calling memcpy internally, but unfortunately I have no guesses as to why that produces the error.
Any ideas what might be causing it and whether there is a way to work around it?
The text was updated successfully, but these errors were encountered:
Good find! I've pushed a fix. It was an off by on error in array_remove_at in which size was used instead of the highest index to get the moved block size.
Minimal scenario to reproduce the issue:
Expecting to see
Getting
If I create array manually using
array_new
, I don't get the same issue. Looking at the source code ofarray_remove_at
I can see there is a call tomemmove
(https://github.com/srdja/Collections-C/blob/master/src/array.c#L317) which I'm guessing is calling memcpy internally, but unfortunately I have no guesses as to why that produces the error.Any ideas what might be causing it and whether there is a way to work around it?
The text was updated successfully, but these errors were encountered: