SDL: Fixed crash if uevent info isn't available

From a547c185ce1dd4739fb7b63a7fd35058e6651b79 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 8 Aug 2022 12:21:40 -0700
Subject: [PATCH] Fixed crash if uevent info isn't available

---
 src/hidapi/linux/hid.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/hidapi/linux/hid.c b/src/hidapi/linux/hid.c
index 6a0ae9fed7d..6507dde7125 100644
--- a/src/hidapi/linux/hid.c
+++ b/src/hidapi/linux/hid.c
@@ -219,7 +219,7 @@ parse_uevent_info(const char *uevent, unsigned *bus_type,
 	unsigned short *vendor_id, unsigned short *product_id,
 	char **serial_number_utf8, char **product_name_utf8)
 {
-	char *tmp = strdup(uevent);
+	char *tmp;
 	char *saveptr = NULL;
 	char *line;
 	char *key;
@@ -229,6 +229,15 @@ parse_uevent_info(const char *uevent, unsigned *bus_type,
 	int found_serial = 0;
 	int found_name = 0;
 
+	if (!uevent) {
+		return 0;
+	}
+
+	tmp = strdup(uevent);
+	if (!tmp) {
+		return 0;
+	}
+
 	line = strtok_r(tmp, "\n", &saveptr);
 	while (line != NULL) {
 		/* line: "KEY=value" */