lua-users home
lua-l archive

Re: Maybe a bug in lundump.c

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


2014年03月19日 19:04 GMT+08:00 云风 <cloudwu@gmail.com>:
> 2014年03月19日 18:47 GMT+08:00 Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>:
>>> In function : void LoadConstants(LoadState* S, Proto* f)
>>>
>>> If the constant is string, it will be call setsvalue2n .
>>>
>>> case LUA_TSTRING:
>>> setsvalue2n(S->L,o,LoadString(S));
>>>
>>> and setsvalue2n crashes if LoadString(S) return NULL.
>>
>> LoadString should never return NULL when called from LoadConstants.
>> There is only one case when LoadString returns NULL: for the chunck source,
>> when debug info has been stripped.
>>
>
> I mean if the input stream is not generate by luac or string.dump,
> LoadString may return NULL .
>
> Do more checking for the corrupted data stream would be better .
>
Raise an error here would be more stable :)
case LUA_TSTRING: {
 TString * s = LoadString(S);
 if (s) {
 setsvalue2n(S->L,o,s);
 } else {
 error(S,"corrupted");
 }
 break;
}
-- 
http://blog.codingnow.com

AltStyle によって変換されたページ (->オリジナル) /