LaurentGomila/SFML — Issue #136: sf::Text crash on destroy when using char buffer
Author: RevenantX
Created: 2011-12-17 16:35:32+00:00
State: open

This code cause to crash
void GGameEngine::DrawDebugText( int x, int y, const char *text, ...)
{
va_list args;
sf::Text debugText;
char buf[1024];

// Formatting text
va_start(args, text);
vsprintf(buf, text, args);
va_end(args);

// Setup text
debugText = sf::Text(buf,debugFont, 12);
debugText.SetPosition((float)x, (float)y);

// Render to screen
window.Draw(debugText);
}

but this not
void GGameEngine::DrawDebugText( int x, int y, const char *text, ...)
{
va_list args;
sf::Text debugText;
char buf[1024];

// Formatting text
va_start(args, text);
vsprintf(buf, text, args);
va_end(args);

// Setup text
debugText = sf::Text("SOME TEXT',debugFont, 12);
debugText.SetPosition((float)x, (float)y);

// Render to screen
window.Draw(debugText);
}