[PATCH] Fix smbtorture memory leaks
David Disseldorp
ddiss at samba.org
Wed May 16 12:29:19 UTC 2018
On Wed, 16 May 2018 13:36:39 +0200, David Disseldorp via samba-technical wrote:
> On Wed, 16 May 2018 12:14:11 +0200, Andreas Schneider via samba-technical wrote:
>
> > - torture_assert_int_equal(tctx, smbc_get ##option(ctx), val, "failed " #option);
> > + torture_assert_int_equal_goto(tctx, smbc_get ##option(ctx), val, ok, done, "failed " #option);
> >
> > #define TEST_OPTION_STRING(option, val) \
> > torture_comment(tctx, "Testing smbc_set" #option "\n");\
> > smbc_set ##option(ctx, strdup(val));\
The strdup() leak here needs to be fixed too. The comment above
justifying the strdup() is wrong as of
2d41b1ab78639abe4ae030ff482573f464564dd7.
> > torture_comment(tctx, "Testing smbc_get" #option "\n");\
> > - torture_assert_str_equal(tctx, smbc_get ##option(ctx), val, "failed " #option);
> > + torture_assert_str_equal_goto(tctx, smbc_get ##option(ctx), val, ok, done, "failed " #option);
>
> Gah, I know this is just test code, but please don't add extra macros
> that use magic labels and variables. My preference would be to just
> move the torture_assert out of the TEST_OPTION_X() macros and into the
> caller.
Hmm, the macros also magically use "tctx" and "ctx". I'd just drop
them altogether.
Cheers, David
More information about the samba-technical
mailing list