Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 77f7f82

Browse files
peffgitster
authored andcommitted
attr: drop misguided defensive coding
In prepare_attr_stack, we pop the old elements of the stack (which were left from a previous lookup and may or may not be useful to us). Our loop to do so checks that we never reach the top of the stack. However, the code immediately afterwards will segfault if we did actually reach the top of the stack. Fortunately, this is not an actual bug, since we will never pop all of the stack elements (we will always keep the root gitattributes, as well as the builtin ones). So the extra check in the loop condition simply clutters the code and makes the intent less clear. Let's get rid of it. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1afca44 commit 77f7f82

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

attr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ static void prepare_attr_stack(const char *path, int dirlen)
568568
* Pop the ones from directories that are not the prefix of
569569
* the path we are checking.
570570
*/
571-
while (attr_stack && attr_stack->origin) {
571+
while (attr_stack->origin) {
572572
int namelen = strlen(attr_stack->origin);
573573

574574
elem = attr_stack;

0 commit comments

Comments
 (0)