Test fix: fixed allocation size used for variable length input
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 7 Jul 2017 20:13:32 +0000 (16:13 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 7 Jul 2017 20:16:36 +0000 (16:16 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/lib/test_plugin.c

index 0d11e0ae5b48296082303981b99eacb327e2b4c8..ad8489e88a27a60ea605886a269168f5eaace91c 100644 (file)
@@ -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,
This page took 0.024086 seconds and 4 git commands to generate.