25 Commits

Author SHA1 Message Date
Nikias Bassen 70fd355f94 libcnary: Fix leak on error in node_copy_deep() 2026-02-13 00:48:34 +01:00
Nikias Bassen 714ef4f956 libcnary: Fix node_detach to fully clear parent relationship
Ensure node_detach() clears child->parent after removal and
handles missing children lists safely. This makes detached
nodes reusable and allows correct rollback when reinserting
nodes after failed inserts (e.g. depth-limit failures).

Without this, detached nodes could remain logically parented,
causing inconsistent state and preventing reinsertion.
2026-02-08 03:54:06 +01:00
Nikias Bassen 1df039994f libcnary: Define error codes and add cycle, depth, and parent guards 2026-02-06 22:08:39 +01:00
Nikias Bassen d390800634 libcnary: Updated typedefs of node_t and node_list_t to contain pointer
This makes the code more readable. Obviously all the code that uses it
is also updated.
2023-02-06 18:28:28 +01:00
Rosen Penev af9b59e6a1 Replace malloc + memset with calloc where appropriate
calloc is faster for big allocations. It's also simpler.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-01-25 16:20:57 +01:00
Martin Szulecki c14849987d Unfold automake variables into multiple lines for maintainability 2020-06-09 18:19:07 +02:00
Martin Szulecki 5ca510afde Remove whitespace errors from all files 2020-06-08 22:47:19 +02:00
Nikias Bassen 6a53de92e2 libcnary: [BUGFIX] Set list->end to NULL when removing last and only element from list
This prevents a UaF in node_list_add. The issue became visible after removing
the last (and only) item from a PLIST_DICT or PLIST_ARRAY node, and then
adding a new item - the item will not make it into the actual dictionary or
array because the list->end pointer points to invalid memory, effectively
causing memory corruption.
2019-09-03 01:21:05 +02:00
Nikias Bassen bec850fe39 libcnary: Remove list.c/list.h and just do everything in node_list.c 2019-01-21 05:11:03 +01:00
Nikias Bassen 4de329327c Remove node_iterator and operate on node list directly to improve memory usage 2018-12-10 02:22:15 +01:00
Nikias Bassen 74536d7a67 libcnary: Remove redundant members from node_t struct 2018-11-28 03:18:39 +01:00
Bastien Nocera 6be3579b2c libcnary: Fix memleak in node_debug()
An iter was created but never destroyed.
2018-07-24 14:11:32 +02:00
Nikias Bassen 1406766a0c libcnary: Remove unused 'node' parameter from node_list_create() 2017-03-28 02:51:25 +02:00
Nikias Bassen 52f3a565de libcnary: Fix possible NULL pointer dereference in node_iterator_create()
When NULL is passed to node_iterator_create() the code tries to access
the begin element of the node list and causes a NULL pointer dereference.
The value of list is checked a few lines down and iterator->value is then
properly assigned in node_iterator_bind().
2016-11-10 02:51:54 +01:00
Martin Szulecki 993f65b3bd Rename "index" variable as it shadows global declaration on older systems 2014-05-20 17:46:06 +02:00
Nikias Bassen 8867ee9306 fix make distcheck 2014-02-13 12:14:31 +01:00
Nikias Bassen 39b3f63d2b libcnary: silence two compiler warnings 2013-12-13 01:12:36 +01:00
Nikias Bassen a798afc8b5 change build system to autotools 2013-12-13 00:44:17 +01:00
Nikias Bassen 6697e49278 libcnary: return removed/detached index in node_list_remove/node_detach 2012-04-24 01:10:46 +02:00
Nikias Bassen 83fa6982df libcnary: fix missing return value and missing variable initialization 2012-01-12 00:29:22 +01:00
Nikias Bassen ed4c858c5f node_list: Fix memory corruption
The corruption occured if you removed the last node from the list
and later add a new node to the list.
2012-01-11 15:26:44 +01:00
Nikias Bassen eb218ff07b Updates libcnary sources (adding license info) 2011-06-25 02:52:07 +02:00
Nikias Bassen c7412d4813 Bundle libcnary for better packaging 2011-06-13 18:30:37 +02:00
Nikias Bassen 3277a11f0b Remove libcnary submodule 2011-06-13 18:28:59 +02:00
Nikias Bassen 94cb55d34d Add submodule libcnary 2011-05-27 02:25:20 +02:00