Skip to contentSkip to conversation

fix git-gui crash due to uninitialized variable

PATCH In review Clemens Buchacher 3 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix git-gui crash due to uninitialized variable

Recently, a clone initiated via git gui on Windows crashed on me due to an "unknown variable cdone". It turns out that there is a code path where this variable is used uninitialized.

---

Looking at the output of display(), it's not clear to me now the function below could ever be called with total=0. But I can't delve into it more deeply right now, and this seems like an obvious fix.

 git-gui/lib/status_bar.tcl |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
git-gui/lib/status_bar.tcl +1 -0
index 95cb449..02111a1 100644
@@ -77,6 +77,7 @@ method start {msg uds} {
 
 method update {have total} {
 	set pdone 0
+	set cdone 0
 	if {$total > 0} {
 		set pdone [expr {100 * $have / $total}]
 		set cdone [expr {[winfo width $w_c] * $have / $total}]
Signature · 1 line
1.7.8
#1 lore raw
Quoted 6 lines · Clemens Buchacher

Recently, a clone initiated via git gui on Windows crashed on me due to an "unknown variable cdone". It turns out that there is a code path where this variable is used uninitialized.

---

Thanks, but Clemens, please don't Cc: me git-gui patches, which I won't take directly.

Pinging Pat.

Quoted 19 lines

Looking at the output of display(), it's not clear to me now the function below could ever be called with total=0. But I can't delve into it more deeply right now, and this seems like an obvious fix.

 git-gui/lib/status_bar.tcl |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
git-gui/lib/status_bar.tcl +1 -0
index 95cb449..02111a1 100644
@@ -77,6 +77,7 @@ method start {msg uds} {
 
 method update {have total} {
 	set pdone 0
+	set cdone 0
 	if {$total > 0} {
 		set pdone [expr {100 * $have / $total}]
 		set cdone [expr {[winfo width $w_c] * $have / $total}]
#2 lore raw
In reply to Clemens Buchacher
Quoted 19 lines · Clemens Buchacher

Recently, a clone initiated via git gui on Windows crashed on me due to an "unknown variable cdone". It turns out that there is a code path where this variable is used uninitialized.

---

Looking at the output of display(), it's not clear to me now the function below could ever be called with total=0. But I can't delve into it more deeply right now, and this seems like an obvious fix.

git-gui/lib/status_bar.tcl | 1 +

1 files changed, 1 insertions(+), 0 deletions(-)
git-gui/lib/status_bar.tcl +0 -0
index 95cb449..02111a1 100644

git-gui/lib/status_bar.tcl method start {msg uds} { · line 83

Quoted 7 lines
git-gui/lib/status_bar.tcl +1 -0
@@ -77,6 +77,7 @@ method start {msg uds} {
 
 method update {have total} {
 	set pdone 0
+	set cdone 0
 	if {$total > 0} {
 		set pdone [expr {100 * $have / $total}]
 		set cdone [expr {[winfo width $w_c] * $have / $total}]

It might be nice to know what kind of conditions triggered this for you, but the patch is fine. Thanks, applied.

Signature · 2 lines
Pat Thoyts                            http://www.patthoyts.tk/
PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD