Skip to contentSkip to conversation

builtin/notes: remove unnecessary free

PATCH In review Carlo Marcelo Arenas Belón 3 participants 3 messages Nov 11, 2018 – Nov 13, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 builtin/notes: remove unnecessary free

511726e4b1 ("builtin/notes: fix premature failure when trying to add the empty blob", 2014-11-09) removed the check for !len but left a call to free the buffer that will be otherwise NULL

---
 builtin/notes.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
builtin/notes.c +1 -3
index c05cd004ab..68062f7475 100644
@@ -255,10 +255,8 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)
 
 	if (get_oid(arg, &object))
 		die(_("failed to resolve '%s' as a valid ref."), arg);
-	if (!(buf = read_object_file(&object, &type, &len))) {
-		free(buf);
+	if (!(buf = read_object_file(&object, &type, &len)))
 		die(_("failed to read object '%s'."), arg);
-	}
 	if (type != OBJ_BLOB) {
 		free(buf);
 		die(_("cannot read note data from non-blob object '%s'."), arg);
Signature · 1 line
2.19.1.856.g8858448bb
#1 lore raw
Quoted 6 lines · Carlo Marcelo Arenas Belón

511726e4b1 ("builtin/notes: fix premature failure when trying to add the empty blob", 2014-11-09) removed the check for !len but left a call to free the buffer that will be otherwise NULL

Quoted 23 lines
---
 builtin/notes.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
builtin/notes.c +1 -4
index c05cd004ab..68062f7475 100644
@@ -255,10 +255,8 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)
 
        if (get_oid(arg, &object))
                die(_("failed to resolve '%s' as a valid ref."), arg);
-       if (!(buf = read_object_file(&object, &type, &len))) {
-               free(buf);
+       if (!(buf = read_object_file(&object, &type, &len)))
                die(_("failed to read object '%s'."), arg);
-       }
        if (type != OBJ_BLOB) {
                free(buf);
                die(_("cannot read note data from non-blob object '%s'."), arg);
--

2.19.1.856.g8858448bb

Signature · 2 lines
Johan Herland, <[email protected]>
www.herland.net