malloc overrides

Yaakov (Cygwin/X) yselkowitz@users.sourceforge.net
Thu Nov 5 17:25:00 GMT 2009


On 05/11/2009 07:18, Dave Korn wrote:
>> extern void _exit (int);
>> extern char* strdup (const char*);
>
>    static int are_we_stuck = 1;
>>
>> char* malloc(unsigned n) {
>        are_we_stuck = 0;
>>      return 0;
>> }
>>
>> int main(void) {
>>      strdup("yo");
>        _exit (are_we_stuck);
>> }
>
>    FTFY.

Funny, as I went to sleep last night I thought of just that solution. 
In practice, though, while it doesn't hang, it doesn't give the correct 
answer either.   As Corinna said, the malloc override needs to be 
functional, in that it allocates memory which can then be free()d.  So 
this isn't going to be quite so simple. :-(


Yaakov

--
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



More information about the Cygwin mailing list