From 34c3a51a05733112b89b339cdd7188381aa052b4 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Wed, 3 Dec 2014 16:08:51 +0200 Subject: [PATCH] unit/test-gatt: Fix possible crash If write fails len would be negative and should not be passed to util_hexdump otherwise it might attempt to access invalid memory. --- unit/test-gatt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unit/test-gatt.c b/unit/test-gatt.c index 12b191976..9a77e09f2 100644 --- a/unit/test-gatt.c +++ b/unit/test-gatt.c @@ -736,11 +736,11 @@ static void test_server(gconstpointer data) len = write(context->fd, pdu.data, pdu.size); + g_assert_cmpint(len, ==, pdu.size); + if (g_test_verbose()) util_hexdump('<', pdu.data, len, test_debug, "GATT: "); - g_assert_cmpint(len, ==, pdu.size); - execute_context(context); } -- 2.47.3