1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-07 06:43:00 +03:00

support: Report NULL blobs explicitly in TEST_COMPARE

Provide an explicit diagnostic if the length is positive, and
do not just crash with a null pointer dereference.  Null pointers
are only valid if the length is zero, so this can only happen with
a faulty test.
This commit is contained in:
Florian Weimer
2019-05-16 14:50:15 +02:00
parent 11b451c886
commit 85b0e1e8a6
2 changed files with 8 additions and 1 deletions

View File

@@ -33,7 +33,9 @@ static void
report_blob (const char *what, const unsigned char *blob,
unsigned long int length, const char *expr)
{
if (length > 0)
if (blob == NULL && length > 0)
printf (" %s (evaluated from %s): NULL\n", what, expr);
else if (length > 0)
{
printf (" %s (evaluated from %s):\n", what, expr);
char *quoted = support_quote_blob (blob, length);