title: Ifstream reading error
body: <p>I have been trying to read a bmp file with ifstream, however it works fine without debugging, when I run it in debug mode it fails. At the beginning I read 54 bytes of info, to get the height and the width of the picture, which are unfortunately -858993460 in debug mode, so the whole size of my picture overflows everytime, so I get a bad allocation error. I use VS 2013, could anyone help me out with this one ?</p>
  
  <pre><code>unsigned char* readBMP(char* filename)
  {
  
  int i;
  char info[54];
  std::ifstream ifs(filename, std::ifstream::binary);
  ifs.read(info, 54);
  
  // extract image height and width from header
  int width = *(int*)&amp;info[18];
  int height = *(int*)&amp;info[22];
  
  int size = 3 * width * height;
  
  char* data = new char[size]; // allocate 3 bytes per pixel
  
  ifs.read(data, size);
  ifs.close();
  return (unsigned char*)data;
  
  }
  </code></pre>