Junio C Hamano  committed 2266bf2

for_each_reflog_ent: do not leak FILE *

The callback function can signal an early return by returning non-zero,
but the function leaked the FILE * opened on the reflog when doing so.

Signed-off-by: Junio C Hamano <>

  • Participants
  • Parent commits 72fe6a5

Comments (0)

Files changed (1)

 	const char *logfile;
 	FILE *logfp;
 	char buf[1024];
+	int ret = 0;
 	logfile = git_path("logs/%s", ref);
 	logfp = fopen(logfile, "r");
 		unsigned char osha1[20], nsha1[20];
 		char *email_end, *message;
 		unsigned long timestamp;
-		int len, ret, tz;
+		int len, tz;
 		/* old SP new SP name <email> SP time TAB msg LF */
 		len = strlen(buf);
 		message += 7;
 		ret = fn(osha1, nsha1, buf+82, timestamp, tz, message, cb_data);
 		if (ret)
-			return ret;
+			break;
-	return 0;
+	return ret;