[tor-commits] [tor/maint-0.4.0] sr: BUG() on NULL sr_state before doing a state_query_*()

nickm at torproject.org nickm at torproject.org
Tue Mar 12 15:03:57 UTC 2019


commit 9eeff921ae7b786d960ea4286d5bba56edaef47f
Author: teor <teor at torproject.org>
Date:   Tue Mar 12 11:09:48 2019 +1000

    sr: BUG() on NULL sr_state before doing a state_query_*()
    
    Part of #29706.
---
 src/or/shared_random_state.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/or/shared_random_state.c b/src/or/shared_random_state.c
index 22a503b89..5011b5c7f 100644
--- a/src/or/shared_random_state.c
+++ b/src/or/shared_random_state.c
@@ -857,6 +857,9 @@ state_query_get_commit(const char *rsa_fpr)
 static void *
 state_query_get_(sr_state_object_t obj_type, const void *data)
 {
+  if (BUG(!sr_state))
+    return NULL;
+
   void *obj = NULL;
 
   switch (obj_type) {
@@ -890,6 +893,9 @@ state_query_get_(sr_state_object_t obj_type, const void *data)
 static void
 state_query_put_(sr_state_object_t obj_type, void *data)
 {
+  if (BUG(!sr_state))
+    return;
+
   switch (obj_type) {
   case SR_STATE_OBJ_COMMIT:
   {
@@ -939,6 +945,9 @@ state_query_put_(sr_state_object_t obj_type, void *data)
 static void
 state_query_del_all_(sr_state_object_t obj_type)
 {
+  if (BUG(!sr_state))
+    return;
+
   switch (obj_type) {
   case SR_STATE_OBJ_COMMIT:
   {
@@ -967,6 +976,9 @@ state_query_del_(sr_state_object_t obj_type, void *data)
 {
   (void) data;
 
+  if (BUG(!sr_state))
+    return;
+
   switch (obj_type) {
   case SR_STATE_OBJ_PREVSRV:
     tor_free(sr_state->previous_srv);





More information about the tor-commits mailing list