From c3d611f7f9ef4866877f1dc085b0cbd316662d29 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Wed, 14 Jan 2009 11:22:18 +0100 Subject: [PATCH] HUD::Ladder::draw was capturing the value of a freed temporary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix from Csaba Halász --- src/Instrumentation/HUD/HUD_ladder.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Instrumentation/HUD/HUD_ladder.cxx b/src/Instrumentation/HUD/HUD_ladder.cxx index 9f3136a1c..9181a82a9 100644 --- a/src/Instrumentation/HUD/HUD_ladder.cxx +++ b/src/Instrumentation/HUD/HUD_ladder.cxx @@ -540,7 +540,9 @@ void HUD::Ladder::draw(void) // draw numbers std::ostringstream str; str << i; - const char *num = str.str().c_str(); + // must keep this string, otherwise it will free the c_str! + string num_str = str.str(); + const char *num = num_str.c_str(); int valign = numoffs.y > 0 ? BOTTOM : numoffs.y < 0 ? TOP : VCENTER; draw_text(lo.x - numoffs.x, lo.y + numoffs.y, num, valign | (numoffs.x == 0 ? CENTER : numoffs.x > 0 ? RIGHT : LEFT));