Major and incompatible overhaul of key_data representation. Fix leaks.
[u/mdw/catacomb] / catcrypt.c
index 967730a..4c343a4 100644 (file)
@@ -313,6 +313,7 @@ static int encrypt(int argc, char *argv[])
   freeenc(e);
   if (s) freesig(s);
   freekem(km);
+  if (fp != stdin) fclose(fp);
   if (of) fclose(ofp);
   key_close(&kf);
   dstr_destroy(&d);
@@ -459,6 +460,7 @@ static int decrypt(int argc, char *argv[])
       key_fulltag(sk, &d);
       printf("INFO good-signature %s\n", d.buf);
     }
+    freesig(s);
   } else if (verb)
     printf("INFO no-signature\n");
 
@@ -499,6 +501,7 @@ static int decrypt(int argc, char *argv[])
        printf("FAIL bad ciphertext chunk: authentication failure\n");
       exit(EXIT_FAILURE);
     }
+    GH_DESTROY(h);
     if (!BLEFT(&b))
       break;
     GC_DECRYPT(c, BCUR(&b), BCUR(&b), BLEFT(&b));
@@ -541,6 +544,7 @@ static int decrypt(int argc, char *argv[])
   GC_DESTROY(cx);
   GM_DESTROY(m);
   freekem(km);
+  if (fp != stdin) fclose(fp);
   if (of) fclose(ofp);
   key_close(&kf);
   dstr_destroy(&d);