proxy: Fix null dereference when reusing slots
authorDaiki Ueno <dueno@redhat.com>
Tue, 16 Oct 2018 16:18:05 +0000 (18:18 +0200)
committerDaiki Ueno <ueno@gnu.org>
Wed, 17 Oct 2018 08:13:32 +0000 (10:13 +0200)
p11-kit/proxy.c

index 11e6165f5f6e27b832f461091a1e1bb63a87f3bf..8eaf205ffb94a5e1a0393e122d5cc292374c1a2f 100644 (file)
@@ -307,7 +307,10 @@ proxy_create (Proxy **res, CK_FUNCTION_LIST **loaded,
                                                        break;
                                        }
                                        py->mappings[py->n_mappings].funcs = funcs;
-                                       py->mappings[py->n_mappings].wrap_slot = j == n_mappings ? py->n_mappings + MAPPING_OFFSET : mappings[j].wrap_slot;
+                                       py->mappings[py->n_mappings].wrap_slot =
+                                               (n_mappings == 0 || j == n_mappings) ?
+                                               py->n_mappings + MAPPING_OFFSET :
+                                               mappings[j].wrap_slot;
                                        py->mappings[py->n_mappings].real_slot = slots[i];
                                        ++py->n_mappings;
                                }