[OpenSER-Devel] parse_avp_spec parameters
Dan Pascu
dan at ag-projects.com
Tue Nov 13 10:27:19 UTC 2007
No comment on this at all?
On Thursday 08 November 2007, Dan Pascu wrote:
> As a note, the pv_parse_spec() function doesn't mimic this behavior
> (even though it calls parse_avp_spec at some point) which is how it
> should be behaving (this is mainly because it needs to pass only a
> chunk of the original str, so it makes a copy).
>
> On the same note though pv_parse_avp_name() does modify its input, same
> as parse_avp_spec() since it sends its arguments in passthrough mode to
> the later function. I'm not sure if pv_parse_avp_name is meant to be
> used directly so it may not matter in its case.
>
> On Thursday 08 November 2007, Dan Pascu wrote:
> > I've noticed that the parse_avp_spec function modifies it's input.
> > The first argument is the avp name that should be parsed and the
> > output values for type and avp_name (2nd and 3rd arguments) should be
> > set. While parsing, if the name argument points to an avp with a
> > string name, the name argument is modified and later assigned to
> > avp_name.
> >
> > I think this should be fixed, otherwise every caller must make a copy
> > of the input name to be sure it is not modified, which is not
> > optimal. Consider the case where the input name is a malloc'ed string
> > and by modifying it, the reference to that memory location is lost
> > causing trouble when an attempt to free it is made.
> >
> > Internally the function should make its own copy if a modified
> > version of the input name is needed.
--
Dan
More information about the Devel
mailing list