Skip to content
Snippets Groups Projects
Commit e9dd4626 authored by Alaric Senat's avatar Alaric Senat Committed by Steve Lhomme
Browse files

lib: avoid negating VLC_EGENERIC error code

`VLC_EGENERIC` is defined to `INT_MIN` and negating as a 32 bits integer
is undefined behavior.
Let's print a custom error message instead, as it will never be a valid
errno value anyway.

Reported by UBSAN:
../../lib/core.c:72:9: runtime error: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
parent 7583f14f
No related branches found
No related tags found
1 merge request!5653lib: avoid negating VLC_EGENERIC error code
Pipeline #486225 passed with stage
in 14 minutes and 21 seconds
......@@ -65,11 +65,13 @@ libvlc_instance_t * libvlc_new( int argc, const char *const *argv )
if (unlikely (p_libvlc_int == NULL))
goto error;
int ret = libvlc_InternalInit( p_libvlc_int, argc + 1, my_argv );
const int ret = libvlc_InternalInit( p_libvlc_int, argc + 1, my_argv );
if (ret != VLC_SUCCESS)
{
libvlc_InternalDestroy( p_libvlc_int );
libvlc_printerr("%s", vlc_strerror_c(-ret));
const char *error = (ret == VLC_EGENERIC) ? _( "Generic VLC error" )
: vlc_strerror_c( -ret );
libvlc_printerr( "%s", error );
goto error;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment