Move duplicated strdup/asprintf code into add_lines
Make gen_diff return NULL if it can't do its thing

Specifically, when adding lines to the diff finished with a "." line,
add_lines will return -1 if any of these lines is a ".", making gen_diff clean
up after itself and return NULL.