Browse Source

tests+timing - silence valgrind warning (memleak)

Karel Miko 8 years ago
parent
commit
e5f25b6553
3 changed files with 5 additions and 1 deletions
  1. 1 0
      demos/timing.c
  2. 3 1
      tests/file_test.c
  3. 1 0
      tests/rsa_test.c

+ 1 - 0
demos/timing.c

@@ -674,6 +674,7 @@ static const struct {
        }
        }
        t2 >>= 2;
        t2 >>= 2;
        fprintf(stderr, "DSA-(%lu, %lu) make_key    took %15"PRI64"u cycles\n", (unsigned long)groups[x].group*8, (unsigned long)groups[x].modulus*8, t2);
        fprintf(stderr, "DSA-(%lu, %lu) make_key    took %15"PRI64"u cycles\n", (unsigned long)groups[x].group*8, (unsigned long)groups[x].modulus*8, t2);
+       dsa_free(&key);
    }
    }
    fprintf(stderr, "\n\n");
    fprintf(stderr, "\n\n");
 }
 }

+ 3 - 1
tests/file_test.c

@@ -23,7 +23,9 @@ int file_test(void)
 
 
    len = sizeof(buf);
    len = sizeof(buf);
    if ((in = fopen(fname, "rb")) == NULL)                                       return CRYPT_FILE_NOTFOUND;
    if ((in = fopen(fname, "rb")) == NULL)                                       return CRYPT_FILE_NOTFOUND;
-   if ((err = hash_filehandle(isha256, in, buf, &len)) != CRYPT_OK)             return err;
+   err = hash_filehandle(isha256, in, buf, &len);
+   fclose(in);
+   if (err != CRYPT_OK)                                                         return err;
    if (compare_testvector(buf, len, exp_sha256, 32, "hash_filehandle", 1))      return 1;
    if (compare_testvector(buf, len, exp_sha256, 32, "hash_filehandle", 1))      return 1;
 
 
    len = sizeof(buf);
    len = sizeof(buf);

+ 1 - 0
tests/rsa_test.c

@@ -193,6 +193,7 @@ static int rsa_compat_test(void)
       fprintf(stderr, "RSA rsa_verify_hash_ex + LTC_PKCS_1_V1_5_NA1 failed\n");
       fprintf(stderr, "RSA rsa_verify_hash_ex + LTC_PKCS_1_V1_5_NA1 failed\n");
       return 1;
       return 1;
    }
    }
+   rsa_free(&pubkey);
 
 
    /* now try to export private/public and compare */
    /* now try to export private/public and compare */
    len = sizeof(buf);
    len = sizeof(buf);