lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


________________________________________
From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Sent: Monday, September 7, 2020 10:55 AM
To: Lua mailing list
Subject: Re: lua_assert in the wrong place

> This lua_assert: https://github.com/lua/lua/blob/6bc0f13505bf5d4f613d725fe008c79e72f83ddf/lstring.c#L206
>
> Should be two lines higher, before the call to luaS_hash, which dereferences str unconditionally.

'luaS_hash' does not dereference 'str' unconditionally, only when 'l' is
not zero. This assertion exists because 'memcpy' should not be called
with a NULL string even when the length is zero.

You're right, sorry about that.