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
On adding an integer to a pointer, the C standard says
If both the pointer operand and the result point to elements of the same array object, or one past the last element of the array object, the evaluation shall not produce an overflow; otherwise, the behavior is undefined.
This means this usage of nk_ptr_add triggers undefined behavior when b->size < size because it causes an overflow, and this can happen when the buffer needs to grow. In fact, I caught this error when trying to compile and run Nuklear for a Zig project, since Zig catches various kinds of undefined behavior in debug mode.
I think the solution is to cast the i parameter of nk_ptr_add to a signed type like ptrdiff_t to avoid the overflow. This requires adding a new type to the list of integer types here.
The text was updated successfully, but these errors were encountered:
On adding an integer to a pointer, the C standard says
This means this usage of
nk_ptr_add
triggers undefined behavior whenb->size
<size
because it causes an overflow, and this can happen when the buffer needs to grow. In fact, I caught this error when trying to compile and run Nuklear for a Zig project, since Zig catches various kinds of undefined behavior in debug mode.I think the solution is to cast the
i
parameter ofnk_ptr_add
to a signed type likeptrdiff_t
to avoid the overflow. This requires adding a new type to the list of integer types here.The text was updated successfully, but these errors were encountered: