Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Buffer overflow  (Read 1457 times)

0 Members and 1 Guest are viewing this topic.

Schecker

  • Newbie
  • *
  • Posts: 4
    • View Profile
Buffer overflow
« on: May 23, 2011, 02:39:15 pm »
This is my Code:

Code: [Select]
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>


////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{
    // Create main window
    sf::RenderWindow App(sf::VideoMode(800, 600), "SFML Fonts");

App.SetFramerateLimit(60);

    // Load a font from a file
    sf::Font MyFont;
    if (!MyFont.LoadFromFile("Fonts/MyFont.ttf", 100))
        return EXIT_FAILURE;

    // Create a graphical string
std::string str;
    sf::String text;
    text.SetText("Hello !\nHow are you ?");
    text.SetFont(MyFont);
    text.SetColor(sf::Color(0, 128, 128));
    text.SetPosition(0.f, 0.f);
    text.SetSize(72.f);

    // Start game loop
    while (App.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
// Character entered
if (Event.Type == sf::Event::TextEntered)
{
// Handle ASCII characters only
if (Event.Text.Unicode < 128)
{
str += static_cast<char>(Event.Text.Unicode);
text.SetText(str);
}
}

            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();
        }

        // Clear screen
        App.Clear();

        // Draw our strings
        App.Draw(text);

        // Finally, display rendered frame on screen
        App.Display();
    }

    return EXIT_SUCCESS;
}


I want to compile it in Release-Mode with Visual Studio 2010. It just says : Buffer-Overflow! What could I do to avoid Buffer-Overflow and where does I get it?
The Stack frame says this: "Stack frame: Fonts.exe!__report_gsfailure() Line 298 + 0x7 Bytes.
Any ideas?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Buffer overflow
« Reply #1 on: May 23, 2011, 02:51:37 pm »
You must recompile SFML, the VC2008 libraries are not compatible with VC2010.
Laurent Gomila - SFML developer

Schecker

  • Newbie
  • *
  • Posts: 4
    • View Profile
Buffer overflow
« Reply #2 on: May 23, 2011, 08:04:34 pm »
Ok, I tried to recompile them. I think that worked. Then I copied and overwrite the old lib's. When I try to debug any SFML Code now, I  get this Error:
1>LINK : fatal error LNK1104: Data "sfml-system-d.lib" can't be opened.
What have I done wrong? I linked them as usual.