From c5265381b555766a9d1f931c5371b987292ee41a Mon Sep 17 00:00:00 2001 From: Christoph Heinrich Date: Sun, 26 Feb 2023 17:28:50 +0100 Subject: [PATCH] client API: reintroduce CONF_TYPE_FLAG for type conversion Changing the CONF_TYPE_FLAG was a bad idea because mpv_node.u.flag continues to be an int, leading to a mismatch in type sizes which can lead to problems with memcpy(). ref. #11373 This partially reverts commit 17d91b9d4d2d208f4a847395198cdbbcad18de93. --- options/m_option.h | 2 ++ player/client.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/options/m_option.h b/options/m_option.h index f179c75494..bcdc1f9fcc 100644 --- a/options/m_option.h +++ b/options/m_option.h @@ -213,6 +213,7 @@ struct m_sub_options { }; #define CONF_TYPE_BOOL (&m_option_type_bool) +#define CONF_TYPE_FLAG (&m_option_type_flag) #define CONF_TYPE_INT (&m_option_type_int) #define CONF_TYPE_INT64 (&m_option_type_int64) #define CONF_TYPE_FLOAT (&m_option_type_float) @@ -232,6 +233,7 @@ struct m_sub_options { // size/alignment requirements for option values in general. union m_option_value { bool bool_; + int flag; // not the C type "bool"! int int_; int64_t int64; float float_; diff --git a/player/client.c b/player/client.c index cf2483b4c2..9b4c83b861 100644 --- a/player/client.c +++ b/player/client.c @@ -970,7 +970,7 @@ void mpv_wakeup(mpv_handle *ctx) // map client API types to internal types static const struct m_option type_conv[] = { [MPV_FORMAT_STRING] = { .type = CONF_TYPE_STRING }, - [MPV_FORMAT_FLAG] = { .type = CONF_TYPE_BOOL }, + [MPV_FORMAT_FLAG] = { .type = CONF_TYPE_FLAG }, [MPV_FORMAT_INT64] = { .type = CONF_TYPE_INT64 }, [MPV_FORMAT_DOUBLE] = { .type = CONF_TYPE_DOUBLE }, [MPV_FORMAT_NODE] = { .type = CONF_TYPE_NODE },