init_domain_components(): Assert that the http->dbuffer and http->dvec are NULL master
authorFabian Keil <fk@fabiankeil.de>
Sun, 4 May 2025 13:13:06 +0000 (15:13 +0200)
committerFabian Keil <fk@fabiankeil.de>
Wed, 18 Jun 2025 03:48:30 +0000 (05:48 +0200)
To detect memory leaks earlier.

urlmatch.c

index b213c3e..7682c9e 100644 (file)
@@ -122,6 +122,7 @@ jb_err init_domain_components(struct http_request *http)
    size_t size;
    char *p;
 
    size_t size;
    char *p;
 
+   assert(http->dbuffer == NULL);
    http->dbuffer = strdup_or_die(http->host);
 
    /* map to lower case */
    http->dbuffer = strdup_or_die(http->host);
 
    /* map to lower case */
@@ -146,6 +147,7 @@ jb_err init_domain_components(struct http_request *http)
    /* save a copy of the pointers in dvec */
    size = (size_t)http->dcount * sizeof(*http->dvec);
 
    /* save a copy of the pointers in dvec */
    size = (size_t)http->dcount * sizeof(*http->dvec);
 
+   assert(http->dvec == NULL);
    http->dvec = malloc_or_die(size);
 
    memcpy(http->dvec, vec, size);
    http->dvec = malloc_or_die(size);
 
    memcpy(http->dvec, vec, size);