summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2012-04-20 14:39:07 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2012-04-20 15:08:03 +1000
commit9fbc1f1af90b4ab4b5154549895ca61387167d26 (patch)
treea396b4963864dffcf5e552dec522ca38203108d7
parent881bbd583dc551dcffeadef67931f80b62b26fa6 (diff)
lib: harden the API against invalid matchesmultiple-match
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--libwacom/libwacom.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/libwacom/libwacom.c b/libwacom/libwacom.c
index 949ab04..69a63c5 100644
--- a/libwacom/libwacom.c
+++ b/libwacom/libwacom.c
@@ -599,6 +599,8 @@ libwacom_update_match(WacomDevice *device, WacomBusType bus, int vendor_id, int
int libwacom_get_vendor_id(WacomDevice *device)
{
+ g_return_val_if_fail(device->match >= 0, -1);
+ g_return_val_if_fail(device->match < device->nmatches, -1);
return device->matches[device->match]->vendor_id;
}
@@ -609,11 +611,15 @@ const char* libwacom_get_name(WacomDevice *device)
int libwacom_get_product_id(WacomDevice *device)
{
+ g_return_val_if_fail(device->match >= 0, -1);
+ g_return_val_if_fail(device->match < device->nmatches, -1);
return device->matches[device->match]->product_id;
}
const char* libwacom_get_match(WacomDevice *device)
{
+ g_return_val_if_fail(device->match >= 0, NULL);
+ g_return_val_if_fail(device->match < device->nmatches, NULL);
return device->matches[device->match]->match;
}
@@ -700,6 +706,8 @@ int libwacom_is_reversible(WacomDevice *device)
WacomBusType libwacom_get_bustype(WacomDevice *device)
{
+ g_return_val_if_fail(device->match >= 0, -1);
+ g_return_val_if_fail(device->match < device->nmatches, -1);
return device->matches[device->match]->bus;
}