From 4a7062f7481bb78e5a1eb6d21a4a6866954edc90 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 7 Jul 2017 16:13:32 -0400 Subject: [PATCH] Test fix: fixed allocation size used for variable length input MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- tests/lib/test_plugin.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/lib/test_plugin.c b/tests/lib/test_plugin.c index 0d11e0ae..ad8489e8 100644 --- a/tests/lib/test_plugin.c +++ b/tests/lib/test_plugin.c @@ -278,6 +278,7 @@ static void test_create_all_from_dir(const char *plugin_dir) static void test_find(const char *plugin_dir) { + int ret; struct bt_plugin *plugin; struct bt_component_class *comp_cls_sink; struct bt_component_class *comp_cls_source; @@ -287,10 +288,9 @@ static void test_find(const char *plugin_dir) "bt_plugin_find() handles NULL"); ok(!bt_plugin_find(NON_EXISTING_PATH), "bt_plugin_find() returns NULL with an unknown plugin name"); - plugin_path = malloc(PATH_MAX * 5); - assert(plugin_path); - sprintf(plugin_path, "%s:/ec1d09e5-696c-442e-b1c3-f9c6cf7f5958:::%s:8db46494-a398-466a-9649-c765ae077629:", + ret = asprintf(&plugin_path, "%s:/ec1d09e5-696c-442e-b1c3-f9c6cf7f5958:::%s:8db46494-a398-466a-9649-c765ae077629:", NON_EXISTING_PATH, plugin_dir); + assert(ret > 0 && plugin_path); g_setenv("BABELTRACE_PLUGIN_PATH", plugin_path, 1); plugin = bt_plugin_find("test_minimal"); ok(plugin, -- 2.34.1