So it turns out (cf bug 792453) that a RGBE file made with Photoshop
starts with "#?RGBE", instead of "#?RADIANCE". Looking up Blender's
implementation, they only use "#?" with a comment clearly saying the
string after can be anything. Since there doesn't seem to be any other
file format starting with the "#?" magic number anyway, I guess we
should just do the same and simply drop any character between "#?" and
the first newline in the file.
While changing the code, amending for this new magic number, I also made
it a bit more robust to random contents. In particular,
g_mapped_file_get_contents() can return NULL, so this has to be checked
before dereferencing its contents. Moreover glib code says that the
returned string is not necessarily zero-terminated, so we must properly
limit searches and comparisons to the data size.