In path_is_in_dir(), if it's about to return NULL (if the function parameters have no path components in common) it tried to free() a string literal, which causes a crash. In the same function, there was a memory leak, because diffed_path was reassigned without being free()'d before.
Fix both problems.