builtin/notes: remove unnecessary free
authorCarlo Marcelo Arenas Belón <carenas@gmail.com>
Sun, 11 Nov 2018 09:49:33 +0000 (01:49 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 13 Nov 2018 03:03:15 +0000 (12:03 +0900)
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

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Acked-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/notes.c
index c05cd004abcbdcd1e4c3d140f3cf4251c416df36..68062f747511cb6f2859ddc64a09809602373ed8 100644 (file)
@@ -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 (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);
                die(_("failed to read object '%s'."), arg);
-       }
        if (type != OBJ_BLOB) {
                free(buf);
                die(_("cannot read note data from non-blob object '%s'."), arg);
        if (type != OBJ_BLOB) {
                free(buf);
                die(_("cannot read note data from non-blob object '%s'."), arg);