]> granicus.if.org Git - jq/commitdiff
Fix block flipping in block_drop_unreferenced
authorMuh Muhten <muh.muhten@gmail.com>
Tue, 26 Feb 2019 02:55:15 +0000 (21:55 -0500)
committerNico Williams <nico@cryptonector.com>
Tue, 26 Feb 2019 16:49:08 +0000 (10:49 -0600)
Since 605bfb3, block_drop_unreferenced actually reverses the order of
instructions in the block it's run against. This bug was hidden by the
fact that normally it's run *twice* against the main program, flipping
it back, and that order of function definitionss doesn't really matter
after symbol resolution.

src/compile.c

index 75929aa91f0d9fb81a3df87510b7ba3f2ea377d7..6592b97ed9d3e1c6ee571114e40a0ccf694c0294 100644 (file)
@@ -503,7 +503,7 @@ block block_drop_unreferenced(block body) {
     if (curr->bound_by == curr && !curr->referenced) {
       inst_free(curr);
     } else {
-      refd = BLOCK(inst_block(curr), refd);
+      refd = BLOCK(refd, inst_block(curr));
     }
   }
   return refd;