There's a discussion in the C and C++ communities whether you're allowed
to use the values of pointers that have been deallocated, if you don't
dereference them. Some argue that it is Undefined Behaviour in spite of
the numeric value stored in the variable not having changed.
Instead of arguing, let's just make sure we don't use the pointers after
they have become dangling. We only needed the offset of how far we've
written into the buffer to restore the state and we have a function that
returns exactly that.
Seen while debugging #259.
Drive-by keep the `buffersize` global variable unchanged until after
`realloc()` has returned with success.
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
encode_half has been moved from compilersupport_p.h to cborinternal_p.h
in commit bfc40dcf90 so include this file
in json2cbor to avoid the following build failure:
/home/buildroot/autobuild/run/instance-0/output/host/bin/microblazeel-linux-gcc -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I./src -std=gnu99 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -c -o tools/json2cbor/json2cbor.o tools/json2cbor/json2cbor.c
tools/json2cbor/json2cbor.c: In function 'decode_json_with_metadata':
tools/json2cbor/json2cbor.c:295:50: warning: implicit declaration of function 'encode_half' [-Wimplicit-function-declaration]
(half = encode_half(v), cbor_encode_half_float(encoder, &half));
^~~~~~~~~~~
/home/buildroot/autobuild/run/instance-0/output/host/bin/microblazeel-linux-gcc -o bin/json2cbor tools/json2cbor/json2cbor.o lib/libtinycbor.so -lcjson -lm
tools/json2cbor/json2cbor.o: In function `decode_json_with_metadata':
(.text+0xe54): undefined reference to `encode_half'
collect2: error: ld returned 1 exit status
Makefile:151: recipe for target 'bin/json2cbor' failed
Fixes:
- http://autobuild.buildroot.net/results/afd8d24f2a4e501264abff618cf421d4bd088ebf
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
TinyCBOR release 0.4.2
This is a bugfix release. Important bugs fixed in this release:
- Fixed builds against a static cJSON
- Fixed MSVC builds
- Fixed builds on freestanding C implementation (no FILE* API)
- Fixed the return value of cbor_encoder_close_container when a previous OOM
condition had been detected
- Fixed the build in strict C89 mode (no C99 extensions)
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
Observed issue on earlier version:
json2cbor.c:157:5: error: for loop initial declarations are only allowed in C99 mode
Note, it's not mandatory for current master branch
since build script already sets the c99 flag,
but it won't cause any harm.
Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com>
Compilation was failing when trying to compile cbordump running make in
tools directory. Add missing dependencies, cbortojson and
cborparser_dup_string to cbordump Makefile.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>