[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: bug in lua.c (Lua-5.0) while embedding the interpreter into bash-2.05
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Fri, 9 Mar 2007 05:01:13 -0300
> I've fixed the problem by calloc() a bigger piece of memory (just 4
> bytes bigger) than necessary for argv[] instead of malloc() for the
> exact amount of memory, i.e., argc*sizeof(char *).
I gather you're running the Lua interpreter via exec (or its variants) from
bash...
(BTW, are you aware of Lua Bash: http://freshmeat.net/projects/luabash/ ?)
Your fix is correct but I think you missunderstand the requirements on argv:
it's an array with argc+1 positions, the last one being NULL. So, you need
to malloc argc+1 positions for argv and set the last one to NULL before
exec'ing an external program.
Here are two references I found:
http://publications.gbdirect.co.uk/c_book/chapter10/arguments_to_main.html
http://www-ccs.ucsd.edu/c/lib_over.html (search for main)
--lhf