mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-25 23:05:21 +02:00
upstream: fix some memleaks in test_helper code
bz#3037 from Jitendra Sharma OpenBSD-Regress-ID: 71440fa9186f5842a65ce9a27159385c6cb6f751
This commit is contained in:
parent
6e76e69dc0
commit
c4ffb72593
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: test_helper.c,v 1.11 2018/11/23 02:53:57 dtucker Exp $ */
|
/* $OpenBSD: test_helper.c,v 1.12 2019/08/02 01:41:24 djm Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011 Damien Miller <djm@mindrot.org>
|
* Copyright (c) 2011 Damien Miller <djm@mindrot.org>
|
||||||
*
|
*
|
||||||
@ -391,6 +391,8 @@ assert_mem(const char *file, int line, const char *a1, const char *a2,
|
|||||||
const void *aa1, const void *aa2, size_t l, enum test_predicate pred)
|
const void *aa1, const void *aa2, size_t l, enum test_predicate pred)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
char *aa1_tohex = NULL;
|
||||||
|
char *aa2_tohex = NULL;
|
||||||
|
|
||||||
if (l == 0)
|
if (l == 0)
|
||||||
return;
|
return;
|
||||||
@ -401,8 +403,12 @@ assert_mem(const char *file, int line, const char *a1, const char *a2,
|
|||||||
r = memcmp(aa1, aa2, l);
|
r = memcmp(aa1, aa2, l);
|
||||||
TEST_CHECK_INT(r, pred);
|
TEST_CHECK_INT(r, pred);
|
||||||
test_header(file, line, a1, a2, "STRING", pred);
|
test_header(file, line, a1, a2, "STRING", pred);
|
||||||
fprintf(stderr, "%12s = %s (len %zu)\n", a1, tohex(aa1, MIN(l, 256)), l);
|
aa1_tohex = tohex(aa1, MIN(l, 256));
|
||||||
fprintf(stderr, "%12s = %s (len %zu)\n", a2, tohex(aa2, MIN(l, 256)), l);
|
aa2_tohex = tohex(aa2, MIN(l, 256));
|
||||||
|
fprintf(stderr, "%12s = %s (len %zu)\n", a1, aa1_tohex, l);
|
||||||
|
fprintf(stderr, "%12s = %s (len %zu)\n", a2, aa2_tohex, l);
|
||||||
|
free(aa1_tohex);
|
||||||
|
free(aa2_tohex);
|
||||||
test_die();
|
test_die();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,6 +433,7 @@ assert_mem_filled(const char *file, int line, const char *a1,
|
|||||||
size_t where = -1;
|
size_t where = -1;
|
||||||
int r;
|
int r;
|
||||||
char tmp[64];
|
char tmp[64];
|
||||||
|
char *aa1_tohex = NULL;
|
||||||
|
|
||||||
if (l == 0)
|
if (l == 0)
|
||||||
return;
|
return;
|
||||||
@ -436,8 +443,10 @@ assert_mem_filled(const char *file, int line, const char *a1,
|
|||||||
r = memvalcmp(aa1, v, l, &where);
|
r = memvalcmp(aa1, v, l, &where);
|
||||||
TEST_CHECK_INT(r, pred);
|
TEST_CHECK_INT(r, pred);
|
||||||
test_header(file, line, a1, NULL, "MEM_ZERO", pred);
|
test_header(file, line, a1, NULL, "MEM_ZERO", pred);
|
||||||
|
aa1_tohex = tohex(aa1, MIN(l, 20));
|
||||||
fprintf(stderr, "%20s = %s%s (len %zu)\n", a1,
|
fprintf(stderr, "%20s = %s%s (len %zu)\n", a1,
|
||||||
tohex(aa1, MIN(l, 20)), l > 20 ? "..." : "", l);
|
aa1_tohex, l > 20 ? "..." : "", l);
|
||||||
|
free(aa1_tohex);
|
||||||
snprintf(tmp, sizeof(tmp), "(%s)[%zu]", a1, where);
|
snprintf(tmp, sizeof(tmp), "(%s)[%zu]", a1, where);
|
||||||
fprintf(stderr, "%20s = 0x%02x (expected 0x%02x)\n", tmp,
|
fprintf(stderr, "%20s = 0x%02x (expected 0x%02x)\n", tmp,
|
||||||
((u_char *)aa1)[where], v);
|
((u_char *)aa1)[where], v);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user