Commit 9e6efd2 1 parent 9a1170d commit 9e6efd2 Copy full SHA for 9e6efd2
File tree 1 file changed +3
-1
lines changed
1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ static IRAM struct mgos_gpio_state *mgos_gpio_get_state(int pin) {
63
63
};
64
64
65
65
static struct mgos_gpio_state * mgos_gpio_get_or_create_state (int pin ) {
66
- struct mgos_gpio_state * s = mgos_gpio_get_state (pin );
66
+ struct mgos_gpio_state * s = mgos_gpio_get_state (pin ), * old_s = NULL ;
67
67
if (s != NULL ) return s ;
68
68
s = (struct mgos_gpio_state * ) calloc (s_num_gpio_states + 1 , sizeof (* s ));
69
69
if (s == NULL ) return NULL ;
@@ -73,10 +73,12 @@ static struct mgos_gpio_state *mgos_gpio_get_or_create_state(int pin) {
73
73
if (s_state != NULL ) {
74
74
memcpy (s , s_state , s_num_gpio_states * sizeof (* s ));
75
75
}
76
+ old_s = s_state ;
76
77
s_state = s ;
77
78
s = & s_state [s_num_gpio_states ++ ];
78
79
s -> pin = pin ;
79
80
mgos_ints_enable ();
81
+ free (old_s );
80
82
return s ;
81
83
}
82
84
You can’t perform that action at this time.
0 commit comments