Skip to content

Commit

Permalink
Fix bug in DeeSeq_AsHeapVectorWithAllocReuseOffset()
Browse files Browse the repository at this point in the history
  • Loading branch information
GrieferAtWork committed Nov 24, 2023
1 parent 516969a commit 5aa031a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/deemon/objects/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ list_assign(List *me, DeeObject *other) {
DeeList_LockEndWrite(me);

/* Free the list state that got created while we loaded `other' */
if unlikely(old_elemv) {
#ifndef __OPTIMIZE_SIZE__
if unlikely(old_elemv)
#endif /* !__OPTIMIZE_SIZE__ */
{
Dee_Decrefv(old_elemv, old_elemc);
Dee_Free(old_elemv);
}
Expand Down
6 changes: 3 additions & 3 deletions src/deemon/objects/seq/fastseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ DeeSeq_AsHeapVectorWithAllocReuse(DeeObject *__restrict self,
DeeObject **new_elemv, **elemv = *p_vector;
DREF DeeObject *iterator, *elem;
#ifdef Dee_MallocUsableSize
size_t elema = Dee_MallocUsableSize(elemv);
size_t elema = Dee_MallocUsableSize(elemv) / sizeof(DREF DeeObject *);
#else /* Dee_MallocUsableSize */
size_t elema = *p_allocated;
#endif /* !Dee_MallocUsableSize */
Expand Down Expand Up @@ -553,7 +553,7 @@ DeeSeq_AsHeapVectorWithAllocReuseOffset(DeeObject *__restrict self,
DeeObject **new_elemv, **elemv = *p_vector;
DREF DeeObject *iterator, *elem;
#ifdef Dee_MallocUsableSize
size_t elema = Dee_MallocUsableSize(elemv);
size_t elema = Dee_MallocUsableSize(elemv) / sizeof(DREF DeeObject **);
#else /* Dee_MallocUsableSize */
size_t elema = *p_allocated;
#endif /* !Dee_MallocUsableSize */
Expand All @@ -572,7 +572,7 @@ DeeSeq_AsHeapVectorWithAllocReuseOffset(DeeObject *__restrict self,
elemv = new_elemv;
*p_vector = new_elemv;
#ifndef Dee_MallocUsableSize
*p_allocated = offset + elemc;
*p_allocated = offset + elemc;
#endif /* !Dee_MallocUsableSize */
}
for (i = 0; i < elemc; ++i) {
Expand Down

0 comments on commit 5aa031a

Please sign in to comment.