<<< Date Index >>>     <<< Thread Index >>>

Re: [PATCH 1 of 4] Try to correct usage of tempfile and *tempfile



Hi,

* Erik Hovland wrote:

# HG changeset patch
# User Erik Hovland <erik@xxxxxxxxxxx>
# Date 1237316584 25200
# Branch HEAD
# Node ID 022494f73fa54edbf039dc866fa9999069dcef51
# Parent  2285978866e2e9c788f62ddb7d0eee53afd2a36c
Try to correct usage of tempfile and *tempfile

Since tempfile is a double pointer checking for tempfile
and then dereferencing with *tempfile is not correct.

A short note on the FREE() macro. When you pass a simple pointer, use
FREE(&p), when passing a double pointer use FREE(p) and add the
__FREE_CHECKED__ comment.  The comment is used by the check_sec.sh
security check script to ensure some pitfals are avoided (which is used
in hg-commit used to commit changes to hg).

Read:

diff --git a/sendlib.c b/sendlib.c
--- a/sendlib.c
+++ b/sendlib.c
@@ -2049,7 +2049,7 @@
    {
      unlink (msg);
      if (tempfile)
-       FREE (tempfile);                /* __FREE_CHECKED__ */
+       FREE (&tempfile);           /* __FREE_CHECKED__ */
      _exit (S_ERR);
    }

The original one is okay since tempfile already is a double
pointer. Otherwise the __FREE_CHECKED__ comment must be removed, too.

Other than that I'm fine with the patch.

Rocco