Преглед изворни кода

Correctly free state string in wd

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Jan Friesse пре 13 година
родитељ
комит
04dac3ff5d
1 измењених фајлова са 4 додато и 1 уклоњено
  1. 4 1
      exec/wd.c

+ 4 - 1
exec/wd.c

@@ -183,7 +183,7 @@ static const char * wd_res_event_to_str(struct cs_fsm* fsm,
  */
  */
 static int32_t wd_resource_state_is_ok (struct resource *ref)
 static int32_t wd_resource_state_is_ok (struct resource *ref)
 {
 {
-	char* state;
+	char* state = NULL;
 	uint64_t last_updated;
 	uint64_t last_updated;
 	uint64_t my_time;
 	uint64_t my_time;
 	uint64_t allowed_period;
 	uint64_t allowed_period;
@@ -200,6 +200,9 @@ static int32_t wd_resource_state_is_ok (struct resource *ref)
 	if (icmap_get_string(key_name, &state) != CS_OK || strcmp(state, "disabled") == 0) {
 	if (icmap_get_string(key_name, &state) != CS_OK || strcmp(state, "disabled") == 0) {
 		/* key does not exist.
 		/* key does not exist.
 		*/
 		*/
+		if (state != NULL)
+			free(state);
+
 		return CS_FALSE;
 		return CS_FALSE;
 	}
 	}