> 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