commit 4fca09464de0b3459fa7942804c07e4064481fa0 from: James Cook via: Thomas Adam date: Thu Sep 21 14:53:04 2023 UTC handle NULL argument to got_diffreg_result_free ok stsp@ commit - 4749fd6f8d9ab2b0010efcd07e36c772ebe89da0 commit + 4fca09464de0b3459fa7942804c07e4064481fa0 blob - 428751fa19345e93f294c2c9ee5ecf5052092a35 blob + 0c5437a04f86df6eb79d9ec6ceb9a8f373d2704f --- lib/diffreg.c +++ lib/diffreg.c @@ -327,6 +327,9 @@ got_diffreg_result_free(struct got_diffreg_result *dif { const struct got_error *err; + if (diffreg_result == NULL) + return NULL; + diff_result_free(diffreg_result->result); diff_data_free(&diffreg_result->left); diff_data_free(&diffreg_result->right); @@ -335,21 +338,3 @@ got_diffreg_result_free(struct got_diffreg_result *dif free(diffreg_result); return err; } - -const struct got_error * -got_diffreg_result_free_left(struct got_diffreg_result *diffreg_result) -{ - diff_data_free(&diffreg_result->left); - memset(&diffreg_result->left, 0, sizeof(diffreg_result->left)); - return got_diffreg_close(diffreg_result->map1, diffreg_result->size1, - NULL, 0); -} - -const struct got_error * -got_diffreg_result_free_right(struct got_diffreg_result *diffreg_result) -{ - diff_data_free(&diffreg_result->right); - memset(&diffreg_result->right, 0, sizeof(diffreg_result->right)); - return got_diffreg_close(NULL, 0, diffreg_result->map2, - diffreg_result->size2); -} blob - 8aae9cbb204baa3c88860e324853c5f81cc36b56 blob + 3557dccae5546b2e9c1b4b688ba94f8a3946ce46 --- lib/got_lib_diff.h +++ lib/got_lib_diff.h @@ -48,10 +48,6 @@ const struct got_error *got_diffreg_output(struct got_ struct got_diffreg_result *, int, int, const char *, const char *, enum got_diff_output_format, int, FILE *); const struct got_error *got_diffreg_result_free(struct got_diffreg_result *); -const struct got_error *got_diffreg_result_free_left( - struct got_diffreg_result *); -const struct got_error *got_diffreg_result_free_right( - struct got_diffreg_result *); const struct got_error *got_diffreg_close(char *, size_t, char *, size_t); const struct got_error *got_merge_diff3(int *, int, FILE *, FILE *, FILE *,