]>
git.ipfire.org Git - thirdparty/openssl.git/blob - test/bio_memleak_test.c
2 * Copyright 2018-2019 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
11 #include <openssl/buffer.h>
12 #include <openssl/bio.h>
16 static int test_bio_memleak(void)
21 const char *str
= "BIO test\n";
24 bio
= BIO_new(BIO_s_mem());
27 bufmem
.length
= strlen(str
) + 1;
28 bufmem
.data
= (char *) str
;
29 bufmem
.max
= bufmem
.length
;
30 BIO_set_mem_buf(bio
, &bufmem
, BIO_NOCLOSE
);
31 BIO_set_flags(bio
, BIO_FLAGS_MEM_RDONLY
);
33 if (BIO_read(bio
, buf
, sizeof(buf
)) <= 0)
36 ok
= strcmp(buf
, str
) == 0;
45 CRYPTO_set_mem_debug(1);
46 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON
);
52 ADD_TEST(test_bio_memleak
);