]> git.mxchange.org Git - flightgear.git/commitdiff
HUD::Ladder::draw was capturing the value of a freed temporary
authorTim Moore <timoore@redhat.com>
Wed, 14 Jan 2009 10:22:18 +0000 (11:22 +0100)
committerTim Moore <timoore@redhat.com>
Wed, 14 Jan 2009 10:22:18 +0000 (11:22 +0100)
Fix from Csaba Halász

src/Instrumentation/HUD/HUD_ladder.cxx

index 9f3136a1cb803e30eb62e929e003e21376d411e5..9181a82a9c2b3a38c7ca6379d94ab51857ef2024 100644 (file)
@@ -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));