<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Feb 2, 2013 at 5:05 AM, Marcus Meissner <span dir="ltr"><<a href="mailto:marcus@jet.franken.de" target="_blank">marcus@jet.franken.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Fri, Feb 01, 2013 at 03:48:27PM -0800, Juan Lang wrote:<br>
> On Fri, Feb 1, 2013 at 3:45 PM, Juan Lang <<a href="mailto:juan.lang@gmail.com">juan.lang@gmail.com</a>> wrote:<br>
><br>
> > Hi Marcus,<br>
> ><br>
> > - � � � � � �add_oid_to_usage(usage, ptr);<br>
> > + � � � � � �usage = add_oid_to_usage(usage, ptr);<br>
> ><br>
> > This looks fine, but would you mind making the same change on line 337?<br>
> ><br>
> > Actually, perhaps I hit sent too early. If this memory allocation fails,<br>
> which is the only situation under which add_oid_to_usage doesn't just<br>
> return its first parameter, it'll immediately crash on the next invocation<br>
> with a NULL pointer dereference.<br>
><br>
> I'm not sure it's worth all the trouble in an out of memory situation.<br>
> Perhaps just remove the return value and let the caller crash.<br>
<br>
</div></div>Actually the loop around checks that as a condition and would lead to return NULL:<br>
<br>
� � � � for (ptr = usageStr, comma = strchr(ptr, ','); usage && ptr && *ptr;<br>
<br>
For the second one the loop around does not catch it.<br>
<br>
I think the add_oid_to_usage() should not even do it this way �and not touch "usage"<br>
at all, but instead return a memory allocation error and let the caller handle it:/<br>
<br>
Or just let it crash.<br></blockquote><div><br></div><div style>Yeah, I think just letting it crash is better than trying to sort it all out. Thanks, and sorry for the confusing and buggy code :/</div><div style>--Juan�</div>
</div></div></div>