JSON_ENC: Fix unit test for MSVC

Previously scripts were defined like this:

    {
        static const char *const script_name = "xxx";

        static const struct script_info script_info = {
            script_name, ...
        };

        return &script_info;
    }

MSVC cannot handle this, presumably because this technically involves a
load from a variable to determine that script_name equals "xxx" and it
is unable to do this during evaluation of a constant initializer list.
Resolve this by changing script_name and script_title to be arrays
instead, allowing the correct pointer values to be filled into
script_info as symbol addresses/relocations rather than dereferences.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23517)
This commit is contained in:
Hugo Landau 2024-02-08 09:41:23 +00:00
parent 2b5a5c87df
commit 1260d0f579

View File

@ -128,8 +128,8 @@ typedef void (*fp_pz_type)(OSSL_JSON_ENC *, const void *, size_t);
#define BEGIN_SCRIPT(name, title, flags) \
static const struct script_info *get_script_##name(void) \
{ \
const char *const script_name = #name; \
const char *const script_title = #title; \
static const char script_name[] = #name; \
static const char script_title[] = #title; \
\
static const struct script_word script_words[] = { \
OP_INIT_FLAGS(flags)