Commit a638a4223d5042c5dd50e482d427572ae106f4c2

Martin Mitas 2017-07-18T19:04:08

md_build_ref_def_hashtable: Fix variable conflict. By copy&paste error, we have used two nested loops to use the same iterator.

diff --git a/md4c/md4c.c b/md4c/md4c.c
index ac1afac..3d58261 100644
--- a/md4c/md4c.c
+++ b/md4c/md4c.c
@@ -1660,7 +1660,7 @@ md_ref_def_cmp_stable(const void* a, const void* b)
 static int
 md_build_ref_def_hashtable(MD_CTX* ctx)
 {
-    int i;
+    int i, j;
 
     if(ctx->n_ref_defs == 0)
         return 0;
@@ -1749,9 +1749,9 @@ md_build_ref_def_hashtable(MD_CTX* ctx)
         qsort(list->ref_defs, list->n_ref_defs, sizeof(MD_REF_DEF*), md_ref_def_cmp_stable);
 
         /* Disable duplicates. */
-        for(i = 1; i < list->n_ref_defs; i++) {
-            if(md_ref_def_cmp(&list->ref_defs[i-1], &list->ref_defs[i]) == 0)
-                list->ref_defs[i] = list->ref_defs[i-1];
+        for(j = 1; j < list->n_ref_defs; j++) {
+            if(md_ref_def_cmp(&list->ref_defs[j-1], &list->ref_defs[j]) == 0)
+                list->ref_defs[j] = list->ref_defs[j-1];
         }
     }