load_subtree(): separate logic for internal vs. terminal entries
commit98c9897d9e40f49cfb416801851656bac494ae40
authorMichael Haggerty <mhagger@alum.mit.edu>
Sat, 26 Aug 2017 08:28:05 +0000 (26 10:28 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sat, 26 Aug 2017 16:21:01 +0000 (26 09:21 -0700)
tree84f291d450285da9b525a0ed293e4ba4cd164926
parentcbeed9aaa500e2c4b8356a08facaa28121e635de
load_subtree(): separate logic for internal vs. terminal entries

There are only two legitimate notes path components:

* A hexadecimal string that fills the rest of the SHA-1

* A two-digit hexadecimal string that constitutes another internal
  node.

So handle those two cases at the top level, and reject others as
non-notes without trying to parse them. The logic separation also
simplifies upcoming changes.

This prevents us from leaking memory for a leaf_node in the case of
wrong-sized paths. There are still memory leaks in this code; they will
be fixed in upcoming commits.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
notes.c