fix totally bugged assertion in cxPropertiesUseStack()

Sun, 13 Oct 2024 16:47:14 +0200

author
Mike Becker <universe@uap-core.de>
date
Sun, 13 Oct 2024 16:47:14 +0200
changeset 929
192a440b99df
parent 928
d2d42cb1d59e
child 930
6540096c17b7

fix totally bugged assertion in cxPropertiesUseStack()

src/properties.c file | annotate | diff | comparison | revisions
tests/test_properties.c file | annotate | diff | comparison | revisions
--- a/src/properties.c	Sun Oct 13 16:44:29 2024 +0200
+++ b/src/properties.c	Sun Oct 13 16:47:14 2024 +0200
@@ -131,7 +131,7 @@
         char *buf,
         size_t capacity
 ) {
-    assert(buf == NULL);
+    assert(prop->buf == NULL);
     prop->buf = buf;
     prop->buf_capacity = capacity;
     prop->buf_size = 0;
--- a/tests/test_properties.c	Sun Oct 13 16:44:29 2024 +0200
+++ b/tests/test_properties.c	Sun Oct 13 16:47:14 2024 +0200
@@ -374,12 +374,15 @@
     cx_testing_allocator_init(&talloc);
     CxAllocator *alloc = &talloc.base;
     CX_TEST_DO {
+        char buffer[512];
+        CxProperties prop;
+        cxPropertiesInitDefault(&prop);
+        cxPropertiesUseStack(&prop, buffer, 512);
+
         const char *str = "key1 = value1\nkey2 = value2\n\n#comment\n\nkey3 = value3\n";
 
         CxMap *map = cxHashMapCreateSimple(CX_STORE_POINTERS);
         cxDefineAdvancedDestructor(map, cxFree, alloc);
-        CxProperties prop;
-        cxPropertiesInitDefault(&prop);
         CxPropertiesSink sink = cxPropertiesMapSink(map);
         sink.data = alloc; // use the testing allocator
         CxPropertiesSource src = cxPropertiesCstrSource(str);

mercurial