This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: odd segfault with my c program using cygwin 1.7


2009/12/2 Dave Korn:
> Andy Koppe wrote:
>> 2009/12/2 jeffunit:
>>> My program ran fine under cygwin 1.5 as well as many versions of linux
>>> including
>>> mandriva 2009, mandriva 2009.1 and mandriva 2010.0
>>>
>>> When compiled with
>>> gcc cal.c -o cal
>>> and run with
>>> cal 2009
>>> I get a segmentation fault.
>>> When I uncomment line 62, the program runs successfully.
>>
>> It's the line after that that has the bug: it's writing to index 432
>> of a 432-element array.
>
> ÂDoesn't look like it does to me:
>
>> Â Â Â Â for(j=0; j<6*72; j++) {
>> Â Â Â Â Â //printf("joe %d\n", j);
>> Â Â Â Â Â string[j] = '\0';
>> Â Â Â }
>
> ÂThat's less than 432, not less than or equal.

You're right, somehow I'd completely misread that, thinking that the
string[j]='\0' is outside the loop.

Sorry,
Andy

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]