mirror of
https://github.com/samba-team/samba.git
synced 2025-01-24 02:04:21 +03:00
lib:replace: Fix memory leak in test_asprintf()
Found by covscan Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
68cb9a0e6c
commit
a9ad677eb8
@ -338,24 +338,30 @@ static int test_setegid(void)
|
||||
|
||||
static int test_asprintf(void)
|
||||
{
|
||||
char *x;
|
||||
char *x = NULL;
|
||||
|
||||
printf("test: asprintf\n");
|
||||
if (asprintf(&x, "%d", 9) != 1) {
|
||||
printf("failure: asprintf [\ngenerate asprintf\n]\n");
|
||||
free(x);
|
||||
return false;
|
||||
}
|
||||
if (strcmp(x, "9") != 0) {
|
||||
printf("failure: asprintf [\ngenerate asprintf\n]\n");
|
||||
free(x);
|
||||
return false;
|
||||
}
|
||||
if (asprintf(&x, "dat%s", "a") != 4) {
|
||||
printf("failure: asprintf [\ngenerate asprintf\n]\n");
|
||||
free(x);
|
||||
return false;
|
||||
}
|
||||
if (strcmp(x, "data") != 0) {
|
||||
printf("failure: asprintf [\ngenerate asprintf\n]\n");
|
||||
free(x);
|
||||
return false;
|
||||
}
|
||||
free(x);
|
||||
printf("success: asprintf\n");
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user