aboutsummaryrefslogtreecommitdiff
path: root/brandt.c
diff options
context:
space:
mode:
authorMarkus Teich <markus.teich@stusta.mhn.de>2016-11-22 00:29:27 +0100
committerMarkus Teich <markus.teich@stusta.mhn.de>2016-11-22 00:29:27 +0100
commite9d1c7ba005dda68148651119234b0ab076302d1 (patch)
tree9b709be51ec7d80a85735ba6e1ac0a516378192e /brandt.c
parent1e83436746c87ae2671a5541a5e020ae61b49555 (diff)
BRANDT_new() returns NULL on parameter failure
Diffstat (limited to 'brandt.c')
-rw-r--r--brandt.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/brandt.c b/brandt.c
index ff106fb..a05731d 100644
--- a/brandt.c
+++ b/brandt.c
@@ -181,17 +181,22 @@ BRANDT_new (BRANDT_CbResult result,
uint16_t m,
int outcome_public)
{
- struct BRANDT_Auction *ret = GNUNET_new (struct BRANDT_Auction);
- struct BRANDT_DescrP *desc = GNUNET_new (struct BRANDT_DescrP);
- struct GNUNET_HashContext *hc = GNUNET_CRYPTO_hash_context_start ();
+ struct BRANDT_Auction *ret;
+ struct BRANDT_DescrP *desc;
+ struct GNUNET_HashContext *hc;
struct GNUNET_TIME_Relative until_start;
+ if (0 == num_prices)
+ return NULL;
+
+ desc = GNUNET_new (struct BRANDT_DescrP);
desc->time_start = GNUNET_TIME_absolute_hton (time_start);
desc->time_round = GNUNET_TIME_relative_hton (time_round);
desc->description_len = htonl (description_len);
desc->k = htons (num_prices);
desc->m = htons (m);
desc->outcome_public = htons (outcome_public);
+ hc = GNUNET_CRYPTO_hash_context_start ();
GNUNET_CRYPTO_hash_context_read (hc,
&desc->time_start,
sizeof (*desc) - sizeof (desc->hash));
@@ -200,6 +205,7 @@ BRANDT_new (BRANDT_CbResult result,
description_len);
GNUNET_CRYPTO_hash_context_finish (hc, &desc->hash);
+ ret = GNUNET_new (struct BRANDT_Auction);
ret->time_start = time_start;
ret->time_round = time_round;
ret->k = num_prices;