Initializing a char array with a string literal appends a nul byte at the
end, which is not something we want.
bool JpegLoader::detect(const string &sig)
{
- static const char jpeg_sig[] = "\xFF\xD8\xFF";
+ static const char jpeg_sig[] = { '\xFF', '\xD8', '\xFF' };
if(sig.size()<sizeof(jpeg_sig))
return false;
- return !sig.compare(0, 3, jpeg_sig);
+ return !sig.compare(0, sizeof(jpeg_sig), jpeg_sig);
}
void JpegLoader::load(Image::Data &data)