From: Noel Power Date: Fri, 15 Apr 2016 11:51:32 +0000 (+0100) Subject: s4:lib:registry: fix 'Conditional jump or move' valgrind error. X-Git-Tag: talloc-2.1.7~173 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=60b2298a73a0a82c4b29b071900293f8b3f8e132;p=thirdparty%2Fsamba.git s4:lib:registry: fix 'Conditional jump or move' valgrind error. smbtorture local.registry.diff.dotreg.test_diff_apply produces the following valgrind trace ==18367== Conditional jump or move depends on uninitialised value(s) ==18367== at 0xA02ED96: reg_dotreg_diff_load (patchfile_dotreg.c:252) ==18367== by 0xA031C6C: reg_diff_load (patchfile.c:375) ==18367== by 0xA0323AB: reg_diff_apply (patchfile.c:542) ==18367== by 0x15F116: test_diff_apply (diff.c:72) ==18367== by 0x955460C: wrap_test_with_simple_test (torture.c:731) ==18367== by 0x955366F: internal_torture_run_test (torture.c:442) ==18367== by 0x9553A4B: torture_run_test_restricted (torture.c:542) ==18367== by 0x260074: run_matching (smbtorture.c:110) ==18367== by 0x25FF36: run_matching (smbtorture.c:95) ==18367== by 0x25FF36: run_matching (smbtorture.c:95) ==18367== by 0x25FF36: run_matching (smbtorture.c:95) ==18367== by 0x260195: torture_run_named_tests (smbtorture.c:143) ==18367== Signed-off-by: Noel Power Reviewed-by: Volker Lendecke Reviewed-by: Andreas Schneider --- diff --git a/source4/lib/registry/patchfile_dotreg.c b/source4/lib/registry/patchfile_dotreg.c index f537b971f7c..49f71f9a7a6 100644 --- a/source4/lib/registry/patchfile_dotreg.c +++ b/source4/lib/registry/patchfile_dotreg.c @@ -249,7 +249,7 @@ _PUBLIC_ WERROR reg_dotreg_diff_load(int fd, while ((line = afdgets(fd, mem_ctx, 0))) { /* Remove '\r' if it's a Windows text file */ - if (line[strlen(line)-1] == '\r') { + if (strlen(line) && line[strlen(line)-1] == '\r') { line[strlen(line)-1] = '\0'; }