[ovs-dev] [flow-stats 06/14] packets: New function eth_from_hex().

Ben Pfaff blp at nicira.com
Thu Dec 15 17:23:55 UTC 2011


On Wed, Dec 14, 2011 at 05:50:39PM -0800, Ansis Atteka wrote:
> On Thu, Dec 8, 2011 at 2:01 PM, Ben Pfaff <blp at nicira.com> wrote:
> > +const char *
> > +eth_from_hex(const char *hex, struct ofpbuf **packetp)
> > +{
> > +    struct ofpbuf *packet;
> > +
> > +    packet = *packetp = ofpbuf_new(strlen(hex) / 2);
> >
> I did not try to apply and test this patch, but it seems that if
> strlen(hex) == 1 (either valid or invalid hex digit),
> then packet->base==NULL after the previous line.

Yes, but that should be OK.  I don't see any code that would try to
dereference packet->base in that case.

> For example later ofpbuf_delete() could try to do free(NULL)...

free(NULL) has been well-defined to do nothing for decades.  We depend
on that behavior elsewhere.



More information about the dev mailing list