diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-07-21 16:53:57 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-07-21 16:53:57 +0200 |
commit | 0eee3574dcb7bf1971a2e106f666caa41f8589f3 (patch) | |
tree | 4fe8115f1bc2af050b61eaff47ed11fd71a06214 | |
parent | c2f515e414a67407bb09c30a16007d15dcd8d860 (diff) | |
download | merchant-0eee3574dcb7bf1971a2e106f666caa41f8589f3.tar.gz merchant-0eee3574dcb7bf1971a2e106f666caa41f8589f3.tar.bz2 merchant-0eee3574dcb7bf1971a2e106f666caa41f8589f3.zip |
-fix NPE
-rw-r--r-- | src/backend/taler-merchant-httpd.c | 2 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_private-post-products-ID-lock.c | 28 |
2 files changed, 14 insertions, 16 deletions
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c index 58f82f35..277f7480 100644 --- a/src/backend/taler-merchant-httpd.c +++ b/src/backend/taler-merchant-httpd.c @@ -928,6 +928,8 @@ TMH_lookup_instance (const char *instance_id) to handle that */ mi = GNUNET_CONTAINER_multihashmap_get (TMH_by_id_map, &h_instance); + if (NULL == mi) + return mi; age = GNUNET_TIME_absolute_get_duration (mi->staleness); if (age.rel_value_us > INSTANCE_STALENESS.rel_value_us) { diff --git a/src/backend/taler-merchant-httpd_private-post-products-ID-lock.c b/src/backend/taler-merchant-httpd_private-post-products-ID-lock.c index 5a27b56f..0fae6023 100644 --- a/src/backend/taler-merchant-httpd_private-post-products-ID-lock.c +++ b/src/backend/taler-merchant-httpd_private-post-products-ID-lock.c @@ -27,14 +27,6 @@ #include <taler/taler_json_lib.h> -/** - * Lock an existing product. - * - * @param rh context of the handler - * @param connection the MHD connection to handle - * @param[in,out] hc context with further information about the request - * @return MHD result code - */ MHD_RESULT TMH_private_post_products_ID_lock (const struct TMH_RequestHandler *rh, struct MHD_Connection *connection, @@ -48,11 +40,11 @@ TMH_private_post_products_ID_lock (const struct TMH_RequestHandler *rh, struct GNUNET_TIME_Relative duration; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("lock_uuid", - &uuid), - GNUNET_JSON_spec_uint32 ("quantity", - &quantity), + &uuid), // FIXME: use string? TALER_JSON_spec_relative_time ("duration", &duration), + GNUNET_JSON_spec_uint32 ("quantity", + &quantity), GNUNET_JSON_spec_end () }; @@ -94,16 +86,20 @@ TMH_private_post_products_ID_lock (const struct TMH_RequestHandler *rh, mi->settings.id, product_id, NULL); + if (GNUNET_DB_STATUS_HARD_ERROR == qs) + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "lookup_product"); if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) return TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, TALER_EC_MERCHANT_GENERIC_PRODUCT_UNKNOWN, product_id); - else - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_GONE, - TALER_EC_MERCHANT_PRIVATE_POST_PRODUCTS_LOCK_INSUFFICIENT_STOCKS, - product_id); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_GONE, + TALER_EC_MERCHANT_PRIVATE_POST_PRODUCTS_LOCK_INSUFFICIENT_STOCKS, + product_id); case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: return TALER_MHD_reply_static (connection, MHD_HTTP_NO_CONTENT, |