Patchwork ccid-card-emulated: handle no backend (fixes segfault)

login
register
mail settings
Submitter Alon Levy
Date May 17, 2011, 10:03 a.m.
Message ID <1305626622-12925-1-git-send-email-alevy@redhat.com>
Download mbox | patch
Permalink /patch/95895/
State New
Headers show

Comments

Alon Levy - May 17, 2011, 10:03 a.m.
During initialization if no "backend=something" attribute is supplied
don't try to call strcmp with second argument being NULL.

Signed-off-by: Alon Levy <alevy@redhat.com>
---
 hw/ccid-card-emulated.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
Markus Armbruster - May 25, 2011, 7:42 a.m.
Alon Levy <alevy@redhat.com> writes:

> During initialization if no "backend=something" attribute is supplied
> don't try to call strcmp with second argument being NULL.

Reviewed-by: Markus Armbruster <armbru@redhat.com>

Patch

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