git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] * remote.c (valid_fetch_refspec): remove useless if-before-free test

From
Jim Meyering <meyering@redhat.com>
Date
Aug 19, 2008, 18:46 UTC
Message-ID
<87k5ecx2pl.fsf@rho.meyering.net>

We removed a handful of these useless if-before-free tests several months ago. This change removes a new one that snuck back in.

Signed-off-by: Jim Meyering <meyering@redhat.com>
---
There are four in regex.c, too, but that's imported code,
so probably not worth modifying in git:
    compat/regex.c: if (var) free (var)
    compat/regex.c: if (preg->buffer != NULL)
        free (preg->buffer)
    compat/regex.c: if (preg->fastmap != NULL)
        free (preg->fastmap)
    compat/regex.c: if (preg->translate != NULL)
        free (preg->translate)
 remote.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/remote.c b/remote.c
index f61a3ab..105668f 100644
--- a/remote.c
+++ b/remote.c
@@ -579,8 +579,7 @@ int valid_fetch_refspec(const char *fetch_refspec_str)
 	struct refspec *refspec;

 	refspec = parse_refspec_internal(1, fetch_refspec, 1, 1);
-	if (refspec)
-		free(refspec);
+	free(refspec);
 	return !!refspec;
 }

--
1.6.0.9.gae2e487
Next: Alex Riesen
Message 1 of 8 in “* remote.c (valid_fetch_refspec): remove useless if-before-free test”
  1. * remote.c (valid_fetch_refspec): remove useless if-before-free testJim Meyering, Aug 19, 2008
  2. Alex RiesenAug 20, 2008
  3. Jim MeyeringAug 20, 2008
  4. Brandon CaseyAug 20, 2008
  5. Junio C HamanoAug 21, 2008
  6. Brandon CaseyAug 21, 2008
  7. Junio C HamanoAug 21, 2008
  8. remote.c: add a function for deleting a refspec array and use it (twice)Brandon Casey, Aug 22, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.