Rich Megginson wrote:
Philip Prindeville wrote:
Rich Megginson wrote:
https://bugzilla.mozilla.org/show_bug.cgi?id=323374
Files: https://bugzilla.mozilla.org/attachment.cgi?id=208698
Diffs: https://bugzilla.mozilla.org/attachment.cgi?id=208699
1) I'm pretty sure the reference to socket should be fd instead. I
don't know why it compiled with socket in there . . . note to self:
read compiler warnings . . .
2) The cert returned by SSL_PeerCertificate is "dup"ed, so we need
to call CERT_DestroyCertificate to release it otherwise we'll leak
references.
3) The hostname returned by SSL_RevealURL is strduped and must be
freed.
Looking at:
+ if (hostname) {
+ PL_strfree(hostname);
+ }
Isn't PL_strfree() -- which calls free() -- NULL safe?
No - see http://lxr.mozilla.org/nspr/ident?i=PL_strfree
Yes, exactly:
PR_IMPLEMENT <http://lxr.mozilla.org/nspr/ident?i=PR_IMPLEMENT>(void)
PL_strfree <http://lxr.mozilla.org/nspr/ident?i=PL_strfree>(char *s
<http://lxr.mozilla.org/nspr/ident?i=s>)
{
free <http://lxr.mozilla.org/nspr/ident?i=free>(s
<http://lxr.mozilla.org/nspr/ident?i=s>);
}
Now reading the man page for free(), we see:
free() frees the memory space pointed to by ptr, which must have
been
returned by a previous call to malloc(), calloc() or realloc().
Oth-
erwise, or if free(ptr) has already been called before,
undefined
behaviour occurs. If ptr is NULL, no operation is performed.
-Philip
So when you check the pointer for non-NULL, you're duplicating
code inside of free().
-Philip
_______________________________________________
dev-tech-ldap mailing list
[EMAIL PROTECTED]
https://lists.mozilla.org/listinfo/dev-tech-ldap