summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/client.c b/client.c
index 641db88..d60c8e1 100644
--- a/client.c
+++ b/client.c
@@ -80,9 +80,11 @@ void icclient_order(icclient_ord_order **orderptr, const char *sku
qsort(items, order->nitems, sizeof(icclient_ord_item *), itemcmp);
icclient_ord_item *key_item = malloc(sizeof(icclient_ord_item));
key_item->product = product;
- item = *(icclient_ord_item **)bsearch(&key_item, items
+ icclient_ord_item **itemptr = bsearch(&key_item, items
, order->nitems, sizeof(icclient_ord_item *)
, itemcmp);
+ if (itemptr)
+ item = *itemptr;
free(key_item);
} else {
*orderptr = malloc(sizeof(icclient_ord_order));