uint32_t* run_time = malloc(required_size + sizeof(uint32_t));
if (required_size > 0) {
err = nvs_get_blob(my_handle, "run_time", run_time, &required_size);
- if (err != ESP_OK) return err;
+ if (err != ESP_OK) {
+ free(run_time);
+ return err;
+ }
}
// Write value including previously saved blob if available
} else {
uint32_t* run_time = malloc(required_size);
err = nvs_get_blob(my_handle, "run_time", run_time, &required_size);
- if (err != ESP_OK) return err;
+ if (err != ESP_OK) {
+ free(run_time);
+ return err;
+ }
for (int i = 0; i < required_size / sizeof(uint32_t); i++) {
printf("%d: %d\n", i + 1, run_time[i]);
}