Skip to content
  • Junio C Hamano's avatar
    handle_options(): do not miscount how many arguments were used · 73546c08
    Junio C Hamano authored
    
    
    The handle_options() function advances the base of the argument array and
    returns the number of arguments it used. The caller in handle_alias()
    wants to reallocate the argv array it passes to this function, and
    attempts to do so by subtracting the returned value to compensate for the
    change handle_options() makes to the new_argv.
    
    But handle_options() did not correctly count when "-c <config=value>" is
    given, causing a wrong pointer to be passed to realloc().
    
    Fix it by saving the original argv at the beginning of handle_options(),
    and return the difference between the final value of argv, which will
    relieve the places that move the array pointer from the additional burden
    of keeping track of "handled" counter.
    
    Noticed-by: Kazuki Tsujimoto
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    Signed-off-by: default avatarJeff King <peff@peff.net>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    73546c08