plugins: Make plugin_name() reliable past unload
commitf7f51f10eb9129dfa9aad030fa9b79a1923059fb
authorEric Blake <eblake@redhat.com>
Thu, 16 Nov 2017 21:08:53 +0000 (16 15:08 -0600)
committerEric Blake <eblake@redhat.com>
Fri, 17 Nov 2017 20:41:14 +0000 (17 14:41 -0600)
tree8d16f62b9d93b411285b0866d7d75b26ddd0b627
parentb5f194fa4ad6a496babd1aa5fac5d8b5a1f06829
plugins: Make plugin_name() reliable past unload

Directly returning storage in the module is risky, because it
means any caller of plugin_name() after unload is getting a
stale pointer, and even callers before unload must strdup() if
they must be sure of the lifetime.  Copying the name into the
heap up front means that plugin_name() can now be safely used
even if unload happens in the meantime.

As long as we have only a single plugin in static storage,
then valgrind knows that it is reachable, and we don't need
to free the copy.

Signed-off-by: Eric Blake <eblake@redhat.com>
src/plugins.c