LCOV - code coverage report
Current view: top level - src/core - config.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 7 7
Test Date: 2026-04-20 19:54:22 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /* SPDX-License-Identifier: GPL-3.0-or-later */
       2              : /* Copyright 2026 Peter Csaszar */
       3              : 
       4              : #include "config.h"
       5              : #include <stdlib.h>
       6              : #include <string.h>
       7              : 
       8              : /**
       9              :  * @brief Frees all heap-allocated fields of cfg, then frees cfg itself.
      10              :  *
      11              :  * Sensitive fields (`token`, `api_base`) are wiped with `explicit_bzero`
      12              :  * before `free()` so the credential cannot be recovered from a post-mortem
      13              :  * core dump or heap inspection (QA-17). `explicit_bzero` is a GNU extension
      14              :  * enabled via the project-wide `_GNU_SOURCE` definition in CMakeLists.txt.
      15              :  */
      16            4 : void config_free(Config *cfg) {
      17            4 :     if (!cfg) return;
      18            3 :     if (cfg->api_base) explicit_bzero(cfg->api_base, strlen(cfg->api_base));
      19            3 :     free(cfg->api_base);
      20            3 :     if (cfg->token) explicit_bzero(cfg->token, strlen(cfg->token));
      21            3 :     free(cfg->token);
      22            3 :     free(cfg);
      23              : }
        

Generated by: LCOV version 2.0-1