fixed memory leaks

This commit is contained in:
TLINDEN
2014-08-08 18:40:53 +02:00
parent 019df8e4c5
commit e022a9e842
6 changed files with 34 additions and 13 deletions

View File

@@ -331,6 +331,8 @@ size_t pcp_ed_detachsign_buffered(Pcpstream *in, Pcpstream *out, pcp_key_t *s) {
char *z85encoded = pcp_z85_encode((byte*)signature, mlen, &zlen, 1);
ps_print(out, "%s\r\n%s\r\n", z85encoded, PCP_SIG_END);
free(signature);
free(z85encoded);
free(st);
return outsize;
@@ -355,6 +357,7 @@ pcp_pubkey_t *pcp_ed_detachverify_buffered(PCPCTX *ptx, Pcpstream *in, Pcpstream
}
crypto_generichash_final(st, hash, crypto_generichash_BYTES_MAX);
free(st);
/* read the sig */
byte *sig = NULL;

View File

@@ -246,8 +246,8 @@ int pcpvault_writeall(PCPCTX *ptx, vault_t *vault) {
if(pcpvault_copy(ptx, tmp, vault) == 0) {
pcpvault_unlink(tmp);
}
free(tmp);
buffer_clear(blob);
pcpvault_free(tmp);
buffer_free(blob);
return 0;
}
}

View File

@@ -297,7 +297,7 @@ char *pcp_z85_encode(byte *raw, size_t srclen, size_t *dstlen, int doblock) {
char *pcp_readz85file(PCPCTX *ptx, FILE *infile) {
byte *input = NULL;
byte *tmp = NULL;
char *out = NULL;
size_t bufsize = 0;
byte byte[1];
@@ -306,19 +306,21 @@ char *pcp_readz85file(PCPCTX *ptx, FILE *infile) {
break;
if(ferror(infile) != 0)
break;
tmp = realloc(input, bufsize + 1);
input = tmp;
input = realloc(input, bufsize + 1);
memmove(&input[bufsize], byte, 1);
bufsize ++;
}
if(bufsize == 0) {
fatal(ptx, "Input file is empty!\n");
free(tmp);
free(input);
return NULL;
}
return pcp_readz85string(ptx, input, bufsize);
out = pcp_readz85string(ptx, input, bufsize);
free(input);
return out;
}
char *pcp_readz85string(PCPCTX *ptx, unsigned char *input, size_t bufsize) {