[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/3] Connect to socket if SPEECHD_ADDRESS begins with /

From: Boris Dušek
Subject: [PATCH 3/3] Connect to socket if SPEECHD_ADDRESS begins with /
Date: Wed, 25 Jul 2012 11:33:04 +0200

24. 7. 2012 v 22:50, Trevor Saunders:

>> +    } else if (env_address[0] == '/') {
>> +            address->method = SPD_METHOD_UNIX_SOCKET;
>> +            address->unix_socket_name = strdup(env_address);
> sadly this isn't a world where malloc has been made infalable (and
> that's probably the way it should stay since this is libspeechd code), and you
> don't immediately dereference the pointer strdup hands you, so you
> should probably handle failure somehow.

good catch, although the surrounding code does not check the return values
of malloc/strdup either.

I solved it by fputs a message on stderr and exiting, since handling stdup
malloc failure by strdup'ing an error string (and returning from the function)
is like to take out a fire with matches :-) I read somewhere that malloc
failures basically should be handled by exit() since when the memory is out
the system must already be in such bad state that there is very little you can 

Also that is what g_strdup (and any function using g_malloc) does.

Please let me know if you agree with such a way so that I can post
such a patch for final review.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]