mirror of
https://github.com/samba-team/samba.git
synced 2025-01-24 02:04:21 +03:00
lib:replace: Fix a memleak in test_strndup()
Found by covscan Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
dca03ffa8a
commit
68cb9a0e6c
@ -264,26 +264,34 @@ static int test_setenv(void)
|
||||
static int test_strndup(void)
|
||||
{
|
||||
char *x;
|
||||
int cmp;
|
||||
|
||||
printf("test: strndup\n");
|
||||
x = strndup("bla", 0);
|
||||
if (strcmp(x, "") != 0) {
|
||||
cmp = strcmp(x, "");
|
||||
free(x);
|
||||
if (cmp != 0) {
|
||||
printf("failure: strndup [\ninvalid\n]\n");
|
||||
return false;
|
||||
}
|
||||
free(x);
|
||||
|
||||
x = strndup("bla", 2);
|
||||
if (strcmp(x, "bl") != 0) {
|
||||
cmp = strcmp(x, "bl");
|
||||
free(x);
|
||||
if (cmp != 0) {
|
||||
printf("failure: strndup [\ninvalid\n]\n");
|
||||
return false;
|
||||
}
|
||||
free(x);
|
||||
|
||||
x = strndup("bla", 10);
|
||||
if (strcmp(x, "bla") != 0) {
|
||||
cmp = strcmp(x, "bla");
|
||||
free(x);
|
||||
if (cmp != 0) {
|
||||
printf("failure: strndup [\ninvalid\n]\n");
|
||||
free(x);
|
||||
return false;
|
||||
}
|
||||
free(x);
|
||||
|
||||
printf("success: strndup\n");
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user