|
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 *). On my laptop % uname -a Darwin libra.local 8.8.0 Darwin Kernel Version 8.8.0: Fri Sep 8 17:18:57 PDT 2006; root:xnu-792.12.6.obj~1/RELEASE_PPC Power Macintosh powerpc % gcc --version powerpc-apple-darwin8-gcc-4.0.0 (GCC) 4.0.0 20041026 (Apple Computer, Inc. build 4061) On my desktop % gcc --version gcc (GCC) 4.0.0 20050519 (Red Hat 4.0.0-8) % uname -a Linux Pegasus 2.6.15 #1 SMP Tue Feb 28 11:50:10 PST 2006 i686 i686 i386 GNU/Linux On 3/8/07, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
> for (i = 1; argv[i] != NULL; i++) { > assumes that an out-of-range i would mean argv[i]==NULL This is required by ANSI C, which is what Lua assumes. > which was not true in my case. Can you give more details? What platform and C compiler? --lhf