]> granicus.if.org Git - jq/commitdiff
Use jv_mem_alloc() in compile.c (fix #771)
authorNicolas Williams <nico@cryptonector.com>
Tue, 28 Apr 2015 15:37:37 +0000 (10:37 -0500)
committerNicolas Williams <nico@cryptonector.com>
Tue, 28 Apr 2015 15:37:37 +0000 (10:37 -0500)
compile.c

index 3aad4ab31313dbe401deaed3133d953b9f9a9d1e..4aa2d2113093e77a4d95902c43426722a2436d4d 100644 (file)
--- a/compile.c
+++ b/compile.c
@@ -365,19 +365,19 @@ block block_bind_library(block binder, block body, int bindflags, const char* li
   bindflags |= OP_HAS_BINDING;
   int nrefs = 0;
   int matchlen = strlen(libname);
-  char* matchname = calloc(1,matchlen+2+1);
+  char* matchname = jv_mem_alloc(matchlen+2+1);
   if (libname[0] != '\0') {
     strcpy(matchname,libname);
-    strcpy(matchname+matchlen,"::");
+    strcpy(matchname+matchlen, "::");
     matchlen += 2;
   }
   assert(block_has_only_binders(binder, bindflags));
   for (inst *curr = binder.first; curr; curr = curr->next) {
     int bindflags2 = bindflags;
     char* cname = curr->symbol;
-    char* tname = malloc(strlen(curr->symbol)+matchlen+1);
+    char* tname = jv_mem_alloc(strlen(curr->symbol)+matchlen+1);
     strcpy(tname, matchname);
-    strcpy(tname+matchlen,cname);
+    strcpy(tname+matchlen, curr->symbol);
 
     // Ew
     if ((opcode_describe(curr->op)->flags & (OP_HAS_VARIABLE | OP_HAS_CONSTANT)))