Skip to content
  • Tobias Mueller's avatar
    gif: Initialise code_last_byte to not cause undefined behaviour · c1fd9f5d
    Tobias Mueller authored and Bastien Nocera's avatar Bastien Nocera committed
    Currently, code_last_byte is set only after it has been used, i.e.
    
        context->block_buf[0] = context->block_buf[context->code_last_byte - 2];
    
    comes before anything has touched context->code_last_byte yet.
    Except for the initialisation.
    context->code_last_byte is set a few lines later, though.
    And nowhere else, except for the initialisation which sets it
    to 0.  That will inevitably lead to context->block_buf[-2] which is
    undefined behaviour.
    
    We hence set the code_last_byte to 2 in order to not make that
    array index invalid.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=778584
    c1fd9f5d