www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples | github

Archive Index This month's Index

Subject: Re: libssh2 master e48907e... avoid a free(NULL)

Re: libssh2 master e48907e... avoid a free(NULL)

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sun, 10 Jan 2010 00:05:21 +0100 (CET)

On Sun, 10 Jan 2010, Mikhail Gusarov wrote:

> l> + if(pubkeydata)
> l> + LIBSSH2_FREE(session, pubkeydata);
> Why it's needed?
> From man free(3): "If ptr is NULL, no operation is performed."

It isn't strictly needed.

I want it for two reasons:

1 - aesthetics. I think calling the callback function to free something when
     we know there's nothing to free is useless.

2 - this triggered a problem in a debug setup of libssh2 that I use,
     that happen to have a trigger on free(NULL) to catch mistakes in the code

  / daniel.haxx.se
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-01-10

the libssh2 team