Additional checks in error paths (#21541)
- Add cleanup for `aclk_query_batch` when the first batch entry fails. - Ensure proper memory release for `config_hash` and `node_id` in alert configuration error paths.
Stelios Fragkakis committed
Jan 14, 2026 at 17:32 UTC
4a17fb44755770870ba0992f88bb9f68e8e375cd
2 files changed
+15
-3
src/database/sqlite/sqlite_aclk.c
+6
@@ -849,6 +849,12 @@ static void aclk_synchronization_event_loop(void *arg)
849
else {
850
aclk_query_free(query);
851
aclk_query_batch->count--;
852
+
853
+ // Clean up the batch structure if this was the first entry that failed
854
+ if (aclk_query_batch->count == 0) {
855
+ freez(aclk_query_batch);
856
+ aclk_query_batch = NULL;
857
+ }
858
break;
859
}
860
src/database/sqlite/sqlite_aclk_alert.c
+9
-3
@@ -751,12 +751,18 @@ void aclk_push_alert_config_event(char *node_id __maybe_unused, char *config_has
751
return;
752
}
753
754
- if (!PREPARE_STATEMENT(db_meta, SQL_SELECT_ALERT_CONFIG, &res))
754
+ nd_uuid_t hash_uuid;
755
+ if (uuid_parse(config_hash, hash_uuid)) {
756
+ freez(config_hash);
757
+ freez(node_id);
758
return;
759
+ }
760
757
- nd_uuid_t hash_uuid;
758
- if (uuid_parse(config_hash, hash_uuid))
761
+ if (!PREPARE_STATEMENT(db_meta, SQL_SELECT_ALERT_CONFIG, &res)) {
762
+ freez(config_hash);
763
+ freez(node_id);
764
return;
765
+ }
766
767
int param = 0;
768
SQLITE_BIND_FAIL(done, sqlite3_bind_blob(res, ++param, &hash_uuid , sizeof(hash_uuid), SQLITE_STATIC));