Skip to content

Commit

Permalink
Make sure we don't call bsr on 0 capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
schveiguy authored and thewilsonator committed Oct 9, 2024
1 parent f115b37 commit f42d5f0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion druntime/src/rt/lifetime.d
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,7 @@ size_t newCapacity(size_t newlength, size_t elemsize)
* growing if 2x would fill up the address space (for 32-bit)
*/
enum largestAllowed = (ulong.max >> 8) & (size_t.max >> 1);
if (newcap & ~largestAllowed)
if (!newcap || (newcap & ~largestAllowed))
return newcap;

/*
Expand Down

0 comments on commit f42d5f0

Please sign in to comment.