Jeffrey Walton
2014-09-24 16:27:29 UTC
I've got a program that repeatedly calls BN_rand_range. Valgrind is
reporting 2.4 MB of leaks.
If I comment out the loop that generates the range value, then the
leak summary drops to 0.
Is there anything else I should be doing below?
**********
Error checking was removed from the sample, but nothing fails.
#include <assert.h>
#include <stdlib.h>
#include <errno.h>
#include <openssl/bn.h>
#define ITERATIONS 1000UL
int main(int argc, char* argv[])
{
UNUSED(argc), UNUSED(argv);
int rc = 0, err;
BIGNUM *range = NULL, *value = NULL;
range = BN_new();
rc = BN_set_word(range, 3);
for(size_t i = 0; i < ITERATIONS; i++)
{
if(value) {
BN_free(value), value = NULL;
}
rc = BN_rand_range(value, range);
}
if(range) {
BN_free(range), range = NULL;
}
if(value) {
BN_free(value), value = NULL;
}
return 0;
}
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users-MCmKBN63+***@public.gmane.org
Automated List Manager majordomo-MCmKBN63+***@public.gmane.org
reporting 2.4 MB of leaks.
If I comment out the loop that generates the range value, then the
leak summary drops to 0.
Is there anything else I should be doing below?
**********
Error checking was removed from the sample, but nothing fails.
#include <assert.h>
#include <stdlib.h>
#include <errno.h>
#include <openssl/bn.h>
#define ITERATIONS 1000UL
int main(int argc, char* argv[])
{
UNUSED(argc), UNUSED(argv);
int rc = 0, err;
BIGNUM *range = NULL, *value = NULL;
range = BN_new();
rc = BN_set_word(range, 3);
for(size_t i = 0; i < ITERATIONS; i++)
{
if(value) {
BN_free(value), value = NULL;
}
rc = BN_rand_range(value, range);
}
if(range) {
BN_free(range), range = NULL;
}
if(value) {
BN_free(value), value = NULL;
}
return 0;
}
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users-MCmKBN63+***@public.gmane.org
Automated List Manager majordomo-MCmKBN63+***@public.gmane.org