[OpenSER-Devel] null socket crash
Henning Westerholt
henning.westerholt at 1und1.de
Fri Oct 12 09:22:32 CEST 2007
On Friday 12 October 2007, Bogdan-Andrei Iancu wrote:
> Hi Juha,
>
> in my opinion, the test should be done outside the function. If you call
> the function, it means you have a valid socket to convert (almost all
> libc function are built on this idea - like if you do a strlen() on a
> NULL pointer, it will crash ;) ).
Hi Bogdan,
ok, but we can it do better than the glibc. ;-)
> Also the calling code may know better if the docket pointer can be null
> or not and to perform the proper checks (there are places where the
> function is used to convert sockets that are known not to be null and
> the test will be just useless).
>
> So, in my opinion, the test should be done in lcr module and not inside
> the function.
For me socket2str is just a datatype conversation function, like we have many
in in the core, e.g. db_str2int, that implements this check. For now the only
code that uses this function is lcr, but this can change over time.
As processing power is much more cheaper than developer brains (and the
overhead of one check is really small), its in my opinion much better to
check this in the function, even if this is sometimes useless.
Cheers,
Henning
More information about the Devel
mailing list