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

Author Topic: Load from file leads to buffer-overflow  (Read 1913 times)

0 Members and 1 Guest are viewing this topic.

ganondorf5

  • Newbie
  • *
  • Posts: 2
    • View Profile
Load from file leads to buffer-overflow
« on: October 14, 2017, 02:10:26 pm »
Hi,

I just try to display a picture with Texture::loadFromFile, but every time I run the program it fails and it seems that my RAM's content is displayed in the consol just after "Failed to load image "". I have left the quotation mark cause the content is displayed just after a quotation mark ! But it's normally the error that is shown between the quotation marks isn't it ?
For the file, I've tried differents images and formats like PNG, JPG, JPEG ...

I'm on Visual Studio 2015 32bits, with the corresponding sfml version, in WINDOW mode and my image file is in the right place (with the .cpp files and in many other places).

Here is my code :
Quote
#include <iostream>
#include <SFML\Graphics.hpp>

using namespace std;
using namespace sf;

int main()
{

   RenderWindow app(VideoMode(800, 600, 32), "My window", Style::Titlebar | Style::Resize | Style::Close);
   app.setVerticalSyncEnabled(true);

   CircleShape shape(100.f);
   shape.setFillColor(Color::Green);

   Texture texture;
   if (!texture.loadFromFile("test.jpeg"))
   {
      cerr << "Error" << endl;
      return EXIT_FAILURE;
   }

   while (app.isOpen())
   {
      Event event;

      while (app.pollEvent(event))
      {
         if (event.type == Event::Closed)
            app.close();
      }

      app.clear();
      app.draw(shape);
      app.display();
   }

   return EXIT_SUCCESS;
}

What's wrong ??

Thanks !
« Last Edit: October 14, 2017, 02:59:44 pm by ganondorf5 »

billarhos

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Load from file leads to buffer-overflow
« Reply #1 on: October 14, 2017, 04:00:36 pm »
Hi, have you the correct path for the texture? Also ".jpeg" may be is ".jpg"

FRex

  • Hero Member
  • *****
  • Posts: 1845
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Load from file leads to buffer-overflow
« Reply #2 on: October 14, 2017, 04:01:03 pm »
What does it mean RAM is displayed in the console? Can you show a screenshot?
Back to C++ gamedev with SFML in May 2023

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10820
    • View Profile
    • development blog
    • Email
Re: Load from file leads to buffer-overflow
« Reply #3 on: October 14, 2017, 04:08:06 pm »
You're mixing release and debug modes, see also: https://www.sfml-dev.org/faq.php#tr-vs-crash
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

ganondorf5

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Load from file leads to buffer-overflow
« Reply #4 on: October 14, 2017, 04:19:33 pm »
Hi, have you the correct path for the texture? Also ".jpeg" may be is ".jpg"
Hi, I've tried those three extensions : png, jpg, jpeg and the result is the same, so I don't think it comes from here...

What does it mean RAM is displayed in the console? Can you show a screenshot?
It means that my console prints some values (in attachment) that must be in my RAM. After a little time, an exception is raised which says that there is a read access violation at the location 0x00BD2000.
So, I think that the function prints my RAM's content in the consol and when it exceed its memory space, there is a buffer overflow and the system raise an exception.

You're mixing release and debug modes, see also: https://www.sfml-dev.org/faq.php#tr-vs-crash
Following you're advice I've unlinked the release libs from my project and it works !

I was thinking that had to link the release and the debug libs in the same time ...
Thank you ! I hope that my mistake will be helpful !