Patchwork [v3,02/28] ccid-card-emul: do not crash if backend is not provided

login
register
mail settings
Submitter Alon Levy
Date April 22, 2013, 3:04 p.m.
Message ID <1366643098-2566-3-git-send-email-alevy@redhat.com>
Download mbox | patch
Permalink /patch/238566/
State New
Headers show

Comments

Alon Levy - April 22, 2013, 3:04 p.m.
From: Marc-André Lureau <marcandre.lureau@gmail.com>

Program received signal SIGSEGV, Segmentation fault.
__strcmp_sse42 () at ../sysdeps/x86_64/multiarch/strcmp-sse42.S:164
164               movdqu        (%rsi), %xmm2
(gdb) bt
    at /home/elmarco/320g/src/qemu/hw/ccid-card-emulated.c:477
    at /home/elmarco/320g/src/qemu/hw/ccid-card-emulated.c:503
---
 hw/usb/ccid-card-emulated.c | 3 +++
 1 file changed, 3 insertions(+)

Patch

diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c
index d534c94..6cbb176 100644
--- a/hw/usb/ccid-card-emulated.c
+++ b/hw/usb/ccid-card-emulated.c
@@ -473,6 +473,9 @@  static uint32_t parse_enumeration(char *str,
 {
     uint32_t ret = not_found_value;
 
+    if (str == NULL)
+        return 0;
+
     while (table->name != NULL) {
         if (strcmp(table->name, str) == 0) {
             ret = table->value;