[vlc-commits] dtv: simplify/clean-up integer parsing
Rémi Denis-Courmont
git at videolan.org
Sat Dec 2 10:08:12 CET 2017
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Dec 2 10:49:28 2017 +0200| [d9ce9c773938d0d0d964a4e4a3b5df6ad6baa79b] | committer: Rémi Denis-Courmont
dtv: simplify/clean-up integer parsing
This works around what looks like an UBSAN bug (refs #19195).
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d9ce9c773938d0d0d964a4e4a3b5df6ad6baa79b
---
modules/access/dtv/linux.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/modules/access/dtv/linux.c b/modules/access/dtv/linux.c
index 6e21e721f7..7a9b24abbc 100644
--- a/modules/access/dtv/linux.c
+++ b/modules/access/dtv/linux.c
@@ -57,16 +57,15 @@ typedef struct
static int icmp (const void *a, const void *b)
{
- int key = (intptr_t)a;
+ const int *key = a;
const dvb_int_map_t *entry = b;
- return key - entry->vlc;
+ return *key - entry->vlc;
}
/** Maps a VLC config integer to a Linux DVB enum value */
static int dvb_parse_int (int i, const dvb_int_map_t *map, size_t n, int def)
{
- const void *k = (const void *)(intptr_t)i;
- const dvb_int_map_t *p = bsearch (k, map, n, sizeof (*map), icmp);
+ const dvb_int_map_t *p = bsearch(&i, map, n, sizeof (*map), icmp);
return (p != NULL) ? p->linux_ : def;
}
More information about the vlc-commits
mailing list