[vlc-devel] [PATCH] misc/variables: prevent crash on missing variable

Steve Lhomme robux4 at ycbcr.xyz
Mon May 20 08:08:20 CEST 2019

On 2019-05-18 18:59, Rémi Denis-Courmont wrote:
> Le lauantaina 18. toukokuuta 2019, 19.53.23 EEST Marvin Scholz a écrit :
>> 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.
> This cannot work, because var_Inherit*() calls cannot return an error, and
> call sites accordingly don't expect one.

All var_Inherit() callers check for an error and return a default value 
if there is one.

Reading the value of a variable knowing the type is wrong doesn't seem 
right. I think this patch is OK.

More information about the vlc-devel mailing list