Skip to content

Commit 646a94b

Browse files
authored
Merge pull request libgit2#4847 from noahp/noahp/null-arg-fixes
tests: πŸŒ€ address two null argument instances
2 parents 5c213e2 + f127ce3 commit 646a94b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

β€Žsrc/apply.cβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,9 @@ static int apply_binary(
348348
&patch->binary.old_file)) < 0)
349349
goto done;
350350

351+
/* Verify that the resulting file with the reverse patch applied matches the source file */
351352
if (source_len != reverse.size ||
352-
memcmp(source, reverse.ptr, source_len) != 0) {
353+
(source_len && memcmp(source, reverse.ptr, source_len) != 0)) {
353354
error = apply_err("binary patch did not apply cleanly");
354355
goto done;
355356
}

β€Žtests/apply/fromfile.cβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ static int apply_patchfile(
4343

4444
if (error == 0) {
4545
cl_assert_equal_i(new_len, result.size);
46-
cl_assert(memcmp(new, result.ptr, new_len) == 0);
46+
if (new_len)
47+
cl_assert(memcmp(new, result.ptr, new_len) == 0);
4748

4849
cl_assert_equal_s(filename_expected, filename);
4950
cl_assert_equal_i(mode_expected, mode);

0 commit comments

Comments
Β (0)