Load_GIF(): more error detection
This commit is contained in:
parent
2d45c5e68b
commit
3bfa777d23
@ -4591,11 +4591,16 @@ void Load_GIF(T_IO_Context * context)
|
|||||||
|
|
||||||
while ( (GIF_get_next_code(GIF_file, &GIF)!=value_eof) && (!File_error) )
|
while ( (GIF_get_next_code(GIF_file, &GIF)!=value_eof) && (!File_error) )
|
||||||
{
|
{
|
||||||
if (GIF.current_code<=alphabet_free)
|
if (GIF.current_code > alphabet_free)
|
||||||
{
|
{
|
||||||
if (GIF.current_code!=value_clr)
|
GFX2_Log(GFX2_INFO, "Load_GIF() Invalid code %u (should be <=%u)\n", GIF.current_code, alphabet_free);
|
||||||
|
File_error=2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (GIF.current_code != value_clr)
|
||||||
{
|
{
|
||||||
if (alphabet_free==(byte_read=GIF.current_code))
|
byte_read = GIF.current_code;
|
||||||
|
if (alphabet_free == GIF.current_code)
|
||||||
{
|
{
|
||||||
GIF.current_code=old_code;
|
GIF.current_code=old_code;
|
||||||
alphabet_stack[alphabet_stack_pos++]=special_case;
|
alphabet_stack[alphabet_stack_pos++]=special_case;
|
||||||
@ -4623,25 +4628,26 @@ void Load_GIF(T_IO_Context * context)
|
|||||||
alphabet_max =((1 << (++GIF.nb_bits))-1);
|
alphabet_max =((1 << (++GIF.nb_bits))-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // Code Clear rencontré
|
else // Clear code
|
||||||
{
|
{
|
||||||
GIF.nb_bits = initial_nb_bits + 1;
|
GIF.nb_bits = initial_nb_bits + 1;
|
||||||
alphabet_max = ((1 << GIF.nb_bits)-1);
|
alphabet_max = ((1 << GIF.nb_bits)-1);
|
||||||
alphabet_free = (1<<initial_nb_bits)+2;
|
alphabet_free = (1<<initial_nb_bits)+2;
|
||||||
special_case = GIF_get_next_code(GIF_file, &GIF);
|
special_case = GIF_get_next_code(GIF_file, &GIF);
|
||||||
|
if (GIF.current_code >= value_clr)
|
||||||
|
{
|
||||||
|
GFX2_Log(GFX2_INFO, "Load_GIF() Invalide code %u just after clear (=%u)!\n",
|
||||||
|
GIF.current_code, value_clr);
|
||||||
|
File_error = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
old_code = GIF.current_code;
|
old_code = GIF.current_code;
|
||||||
GIF_new_pixel(context, &GIF, &IDB, is_transparent, GIF.current_code);
|
GIF_new_pixel(context, &GIF, &IDB, is_transparent, GIF.current_code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
if (File_error == 2 && GIF.pos_X == 0 && GIF.pos_Y == IDB.Image_height)
|
||||||
File_error=2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} // Code End-Of-Information ou erreur de fichier rencontré
|
|
||||||
if (File_error==2 && GIF.pos_X==0 && GIF.pos_Y==IDB.Image_height)
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
/*Close_lecture();*/
|
|
||||||
|
|
||||||
if (File_error >= 0 && !GIF.stop)
|
if (File_error >= 0 && !GIF.stop)
|
||||||
File_error=2;
|
File_error=2;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user