I found an inconsistent behavior in the cJSON_AddItemReferenceToObject API that appears up to commit version v1.7.17.
As you see in the following example, cJSON_AddItemReferenceToObject allows to append a string to a string.
From my understanding, it is treating the cjson_0 as a dictionary.
Moreover, the return value of cJSON_AddItemReferenceToObject indicates the object manipulation was correct.
However, this behaviors leads to inconsistent results and strange memory corruptions.
I found an inconsistent behavior in the
cJSON_AddItemReferenceToObject
API that appears up to commit versionv1.7.17
. As you see in the following example,cJSON_AddItemReferenceToObject
allows to append a string to a string. From my understanding, it is treating thecjson_0
as a dictionary. Moreover, the return value ofcJSON_AddItemReferenceToObject
indicates the object manipulation was correct. However, this behaviors leads to inconsistent results and strange memory corruptions.The output of this example is:
Where
cjson_0
andcjson_1
print the same object (i.e., a string), but the address of the objects is different.Minimal test:
Compilation: