gnokii-users
[Top][All Lists]
Advanced

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

Re: Problem with gnokii 0.6.31git, smsd segmentation fault


From: Jan Derfinak
Subject: Re: Problem with gnokii 0.6.31git, smsd segmentation fault
Date: Tue, 7 Jun 2011 13:13:45 +0200 (CEST)
User-agent: Alpine 2.00 (LNX 1167 2008-08-23)

On Tue, 7 Jun 2011, Pawel Kot wrote:

> > What you think about such change:
> > GNOKII_API gn_error gn_sms_send(gn_data *data, struct gn_statemachine
> > *state, unsigned int **reference)
> > ...
> 
> Quite frankly it does not look nice to me. Why is it disturbing to
> have it? If you are afraid of proper deallocation, let's introduce
> gn_sms_free().

It is not problem with deallocation but with design. The function does a
hidden modification of input data in such way that they are not usable again.
And there is no reason to do that. I find this as very bad practise and
working with such function is dangerous and can lead as smsd case to
segfaults.
There are two drawbacks of the design:
1. You cannot reuse input data because these are damaged after use
   gn_sms_send.
2. You must explicitly deallocate (unneeded) data allocated (hidden)
   somewhere inside libgnokii.

The design I suggest is common in libc, for exmaple look at strtol function.


Jan


-- 



reply via email to

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