Fixed memory leak.

This commit is contained in:
Armin Novak 2014-11-17 00:47:54 +01:00
parent dac7c178a1
commit ee8563504d
1 changed files with 25 additions and 1 deletions

View File

@ -508,7 +508,12 @@ int makecert_context_output_certificate_file(MAKECERT_CONTEXT* context, char* pa
bio = BIO_new(BIO_s_mem()); bio = BIO_new(BIO_s_mem());
if (!bio) if (!bio)
{
free(filename);
free(fullpath);
fclose (fp);
return -1; return -1;
}
status = i2d_PKCS12_bio(bio, context->pkcs12); status = i2d_PKCS12_bio(bio, context->pkcs12);
@ -516,10 +521,24 @@ int makecert_context_output_certificate_file(MAKECERT_CONTEXT* context, char* pa
length = 2048; length = 2048;
x509_str = (BYTE*) malloc(length); x509_str = (BYTE*) malloc(length);
if (!x509_str)
{
free(filename);
free(fullpath);
fclose (fp);
return -1;
}
status = BIO_read(bio, x509_str, length); status = BIO_read(bio, x509_str, length);
if (status < 0) if (status < 0)
{
free(x509_str);
free(filename);
free(fullpath);
fclose (fp);
return -1; return -1;
}
offset += status; offset += status;
@ -537,8 +556,13 @@ int makecert_context_output_certificate_file(MAKECERT_CONTEXT* context, char* pa
} }
if (status < 0) if (status < 0)
{
free(x509_str);
free(filename);
free(fullpath);
fclose (fp);
return -1; return -1;
}
length = offset; length = offset;
fwrite((void*) x509_str, length, 1, fp); fwrite((void*) x509_str, length, 1, fp);