test-json: do not pass ephemeral array as intializer to JSON_BUILD_STRV
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 10 Feb 2019 17:31:54 +0000 (18:31 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 11 Feb 2019 10:53:07 +0000 (11:53 +0100)
commit14648b762f90b72a356e745cee3435531203704a
treee4dc25a590b0c394f43b41f2e4439165bde8552b
parented2dc503da57b0110819563e0d1c85d023435e07
test-json: do not pass ephemeral array as intializer to JSON_BUILD_STRV

Fixes #11600.

The code was effectively doing:
  json_build(..., ({ char **_x = ((char**) ((const char*[]) {"one", "two", "three", "four", NULL })); _x; }));
but there was no guarantee that the storage for the array that _x points to
survives pass the end of the block. Essentially, STRV_MAKE cannot be used
inline inside of a block like this.
src/test/test-json.c