This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] selftest.c: gracefully handle NULL in assert_streq


On 07/19/2016 07:04 AM, David Malcolm wrote:
If a NULL is passed in as the expected or actual value for an
ASSERT_STREQ, the call to strcmp within selftest::assert_streq
can segfault, leading to a failure of -fself-test without
indicating which test failed.

Handle this more gracefully by checking for NULL, so that
information on the failing test is printed to stderr if this
occurs.

Successfully bootstrapped&regrtested on x86_64-pc-linux-gnu.
I also manually tested the various kinds of failure of
ASSERT_STR_EQ, and verified that each branch prints a sane
failure message before aborting.

OK for trunk?

gcc/ChangeLog:
	* selftest.c (selftest::assert_streq): Handle NULL values of
	val_actual and val_expected.
OK.
jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]