]> git.neil.brown.name Git - wiggle.git/commitdiff
vpatch: fix problems reported by valgrind.
authorNeilBrown <neil@brown.name>
Sat, 29 Aug 2020 04:17:02 +0000 (14:17 +1000)
committerNeilBrown <neil@brown.name>
Sat, 29 Aug 2020 04:17:02 +0000 (14:17 +1000)
test code isn't much good if you don't run it...

I ran 'make vtest' and fixed the problems reported.

Signed-off-by: NeilBrown <neil@brown.name>
Makefile
dovtest
vpatch.c
wiggle.h

index 227a0f89ef098e5e54b3a33618dd0b07eab35f96..231106740eab07fba2f0866c271bdc0242dba377 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -46,7 +46,7 @@ QUIET_CLEAN   = $(Q:@=@echo    '     CLEAN    '$@;)
 
 
 $(BIN)/wiggle : $(BOBJ) $(O)/libwiggle.a
-       $(QUIET_LINK)$(CC) $^ $(LDLIBS) -o $@
+       $(QUIET_LINK)$(CC) $(CFLAGS) $^ $(LDLIBS) -o $@
 
 $(O)/libwiggle.a : $(BLIBOBJ)
        $(QUIET_AR)ar cr $@ $^
diff --git a/dovtest b/dovtest
index b38bb46ee16ac2b611d7e3caa0c8e6a27461a657..bcb3c65d469c233aeb2855390108d07d12c9dda4 100755 (executable)
--- a/dovtest
+++ b/dovtest
@@ -41,7 +41,7 @@ do
     else $VG $WIGGLE -B  orig
     fi
     if grep 'ERROR SUMMARY: [1-9]' $vallog > /dev/null 2>&1
-    then msg="VALGRIND ERRORS"; xit=1
+    then msg="VALGRIND ERRORS"; xit=1 ; mv $vallog $vallog-${dir////-}
     else msg="SUCCESS"; xit=0
     fi
     echo $path $msg
index 47e6319fa310d7c8fb80ac594dcf135234e7e846..601408bc8a157df5ec9865c246a574cfb9ec85e9 100644 (file)
--- a/vpatch.c
+++ b/vpatch.c
@@ -1619,6 +1619,7 @@ static int merge_window(struct plist *p, FILE *f, int reverse, int replace,
                        while (spos.p.m >= 0 && spos.state != 0)
                                prev_mline(&spos, fm, fb, fa, ci.merger, smode);
                        while (!same_mpos(spos, tpos) &&
+                              spos.p.m >= 0 &&
                               ci.merger[spos.p.m].type != End)
                                next_mline(&spos, fm, fb, fa, ci.merger, smode);
 
@@ -1636,7 +1637,8 @@ static int merge_window(struct plist *p, FILE *f, int reverse, int replace,
                                blank(i--, 0, cols, a_void);
                        tpos = spos;
                        for (i = srow;
-                            i < rows && ci.merger[tpos.p.m].type != End;
+                            i < rows && tpos.p.m >= 0 &&
+                            ci.merger[tpos.p.m].type != End;
                             i++) {
                                draw_mline(smode, i, start, cols, fm, fb, fa, ci.merger,
                                           tpos,
index 0de65b264f3dc5d4e84892ee0948d7bc8ec6b012..0aa759bdc6f28d768f3ecb2982b1a83ce259aec4 100644 (file)
--- a/wiggle.h
+++ b/wiggle.h
@@ -45,7 +45,7 @@ struct stream {
  * elmnt at the start of each hunk which starts with '\0' and
  * records the line offsets of the hunk.  These are 20+ bytes long.
  * "\0\d{5} \d{5} \d{5}{SP funcname}?\n\0"
- * The 3 numbers are: chunk number, starting line, number if lines.
+ * The 3 numbers are: chunk number, starting line, number of lines.
  * An element with len==0 marks EOF.
  */
 struct elmnt {