Skip to contentSkip to conversation

refs: release strbuf after use in check_refname_component()

PATCH In review René Scharfe 3 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 refs: release strbuf after use in check_refname_component()

---
 refs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
refs.c +1 -1
index 5fcacc6..ed3b2cb 100644
@@ -2334,7 +2334,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
 			struct strbuf err = STRBUF_INIT;
 			unable_to_lock_message(ref_file, errno, &err);
 			error("%s", err.buf);
-			strbuf_reset(&err);
+			strbuf_release(&err);
 			goto error_return;
 		}
 	}
Signature · 1 line
2.2.1
#1 lore raw
Quoted 10 lines · René Scharfe
---
 refs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
refs.c +0 -0
index 5fcacc6..ed3b2cb 100644

refs.c static struct ref_lock *lock_ref_sha1_basic(const char *refname, · line 2340

Quoted 8 lines
refs.c +1 -1
@@ -2334,7 +2334,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
 			struct strbuf err = STRBUF_INIT;
 			unable_to_lock_message(ref_file, errno, &err);
 			error("%s", err.buf);
-			strbuf_reset(&err);
+			strbuf_release(&err);
 			goto error_return;
 		}
 	}

The subject does not seem to match what the patch is doing, but the patch is obviously correct ;-)

#2 lore raw
Quoted 7 lines · Junio C Hamano
Quoted 5 lines · René Scharfe
---
 refs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines

refs.c static struct ref_lock *lock_ref_sha1_basic(const char *refname, · line 2340

Quoted 13 lines
refs.c +1 -1
index 5fcacc6..ed3b2cb 100644
@@ -2334,7 +2334,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
 			struct strbuf err = STRBUF_INIT;
 			unable_to_lock_message(ref_file, errno, &err);
 			error("%s", err.buf);
-			strbuf_reset(&err);
+			strbuf_release(&err);
 			goto error_return;
 		}
 	}

The subject does not seem to match what the patch is doing, but the patch is obviously correct ;-)

The worst part of this is that I got it right in my hacked-up version:

http://article.gmane.org/gmane.comp.version-control.git/259853

but then after much discussion, we dropped all of the lead-in patches, and I sent Ronnie's unedited:

http://article.gmane.org/gmane.comp.version-control.git/259911

All that looking and I didn't notice the release/reset difference between our two versions. Sheesh.

Which is all a roundabout way of saying "yes, René's patch is obviously correct". :)

-Peff