[vlc-devel] [PATCH] misc/variables: prevent crash on missing variable
Marvin Scholz
epirat07 at gmail.com
Sat May 18 18:53:23 CEST 2019
From: Filip Roséen <filip at atch.se>
As var_Inherit will read from the config if the variable is not found
in the inherit-chain, the call to (for example) config_GetInt might
crash due to the variable not existing. We might also run into
undefined-behavior if the caller specifies a type which is not
compatible with the underlying config-type.
This added check fixes the issue by making sure that the type passed
matches that of the configuration, otherwise an error is returned.
---
src/misc/variables.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/misc/variables.c b/src/misc/variables.c
index d53364258a..e467941ad5 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -1032,6 +1032,9 @@ int var_Inherit( vlc_object_t *p_this, const char *psz_name, int i_type,
return VLC_SUCCESS;
}
+ if( config_GetType( psz_name ) != i_type )
+ return VLC_ENOVAR;
+
/* else take value from config */
switch( i_type & VLC_VAR_CLASS )
{
--
2.17.1 (Apple Git-112)
More information about the vlc-devel
mailing list