Fixed memory leak

This commit is contained in:
Armin Novak 2014-11-17 00:13:50 +01:00
parent 3d108f0bca
commit 8302b169d0
1 changed files with 36 additions and 0 deletions

View File

@ -551,7 +551,12 @@ int makecert_context_output_certificate_file(MAKECERT_CONTEXT* context, char* pa
bio = BIO_new(BIO_s_mem());
if (!bio)
{
free(filename);
free(fullpath);
fclose (fp);
return -1;
}
status = PEM_write_bio_X509(bio, context->x509);
@ -562,7 +567,12 @@ int makecert_context_output_certificate_file(MAKECERT_CONTEXT* context, char* pa
status = BIO_read(bio, x509_str, length);
if (status < 0)
{
free(filename);
free(fullpath);
fclose (fp);
return -1;
}
offset += status;
@ -580,7 +590,14 @@ int makecert_context_output_certificate_file(MAKECERT_CONTEXT* context, char* pa
}
if (status < 0)
{
if (x509_str)
free (x509_str);
free(filename);
free(fullpath);
fclose (fp);
return -1;
}
length = offset;
@ -594,7 +611,12 @@ int makecert_context_output_certificate_file(MAKECERT_CONTEXT* context, char* pa
bio = BIO_new(BIO_s_mem());
if (!bio)
{
free(filename);
free(fullpath);
fclose (fp);
return -1;
}
status = PEM_write_bio_PrivateKey(bio, context->pkey, NULL, NULL, 0, NULL, NULL);
@ -605,7 +627,14 @@ int makecert_context_output_certificate_file(MAKECERT_CONTEXT* context, char* pa
status = BIO_read(bio, x509_str, length);
if (status < 0)
{
if (x509_str)
free(x509_str);
free(filename);
free(fullpath);
fclose (fp);
return -1;
}
offset += status;
@ -623,7 +652,14 @@ int makecert_context_output_certificate_file(MAKECERT_CONTEXT* context, char* pa
}
if (status < 0)
{
if (x509_str)
free(x509_str);
free(filename);
free(fullpath);
fclose (fp);
return -1;
}
length = offset;