]> git.seodisparate.com - c_simple_http/commitdiff
Fix inconsistent http_template output size
authorStephen Seo <seo.disparate@gmail.com>
Thu, 5 Sep 2024 07:18:28 +0000 (16:18 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Thu, 5 Sep 2024 07:18:28 +0000 (16:18 +0900)
src/http_template.c
src/test.c

index 012ed7a5a0d22584981682d9e3887bee8b111cb4..b1d6c3a93d18b7a141ef3eddecac869cd8e529ac 100644 (file)
@@ -145,7 +145,7 @@ char *c_simple_http_path_to_generated(
     size_t stored_html_size = strlen(stored_html) + 1;
     html_buf = malloc(stored_html_size);
     memcpy(html_buf, stored_html, stored_html_size);
-    html_buf_size = stored_html_size;
+    html_buf_size = stored_html_size - 1;
   }
 
   // At this point, html_buf contains the raw HTML as a C-string.
index fb2cb0d1a90902baa584b667deb245147b08f64e..8aab8d8cbb7238316a939b52015e962cd6ec5463 100644 (file)
@@ -254,7 +254,7 @@ int main(void) {
     char *buf = c_simple_http_path_to_generated("/", &config, &output_buf_size);
     ASSERT_TRUE(buf != NULL);
     ASSERT_TRUE(strcmp(buf, "<h1>Test</h1>") == 0);
-    CHECK_TRUE(output_buf_size == 14);
+    CHECK_TRUE(output_buf_size == 13);
     simple_archiver_helper_cleanup_c_string(&buf);
 
     __attribute__((cleanup(test_internal_cleanup_delete_temporary_file)))
@@ -294,7 +294,7 @@ int main(void) {
         buf,
         "<h1> Some text. </h1><br><h2> More text. </h2>")
       == 0);
-    CHECK_TRUE(output_buf_size == 47);
+    CHECK_TRUE(output_buf_size == 46);
     simple_archiver_helper_cleanup_c_string(&buf);
 
     __attribute__((cleanup(test_internal_cleanup_delete_temporary_file)))