Commit Graph

156 Commits

Author SHA1 Message Date
iggyvolz
08f1898ba0
Adds test_hash_collisions to .gitignore (#175) 2021-12-28 09:10:58 +01:00
Krzysztof Gabis
af848c27b4 1.3.0: Adds json_set_float_serialization_format function. 2021-12-11 18:11:18 +01:00
Krzysztof Gabis
fd77bcddc1 1.2.1: Not using SIZE_MAX macro (issue #167) 2021-08-06 15:46:45 +02:00
Krzysztof Gabis
6b3d6f42f2 1.2.0: JSON objects are now implemented using hash maps, PARSON_VERSION defines (issue #37) 2021-08-05 20:24:57 +02:00
Krzysztof Gabis
8ed9ff63b0
Update README.md 2021-06-07 21:16:11 +02:00
Krzysztof Gabis
2d7b3ddf12 1.1.3: Ignoring floating point underflow (issue #161) 2021-05-26 14:01:51 +02:00
Disconnect3d
ab7f5e5401
Fix memleak when parsing keys with embedded null bytes (#157)
* Fix memleak when parsing key with embedded null byte

This commit fixes and adds a test for a memory leak that occurs when
parsing strings with keys that have a null byte embedded in them.

This memory leak can be triggered with the following line, where this
call returns a `NULL`:
```c
        json_parse_string("{\"\\u0000\"")
```

This memory leak happens in the `parse_object_value` function in here:
```
        new_key = get_quoted_string(string, &key_len);  <---- ALLOCATION
        /* We do not support key names with embedded \0 chars */
        if (new_key == NULL || key_len != strlen(new_key)) {
            json_value_free(output_value);
            return NULL;                       <---- `new_key` NOT FREED
        }
        SKIP_WHITESPACES(string);
        if (**string != ':') {
            parson_free(new_key);
            json_value_free(output_value);
            return NULL;
        }
```

* Increments version to 1.1.2

Co-authored-by: Krzysztof Gabis <kgabis@gmail.com>
2021-05-03 18:47:03 +02:00
benswick
60b2c69f17
Improved serialization performance (#156)
* Update parson.c

Get objects by index instead of key in json_serialize_to_buffer_r().

* Increments version and updates licence date.

Co-authored-by: Krzysztof Gabis <kgabis@gmail.com>
2021-04-07 22:23:01 +02:00
Tim Gates
8beeb5ea4d
docs: fix simple typo, lighweight -> lightweight (#147)
There is a small typo in README.md.

Should read `lightweight` rather than `lighweight`.
2020-10-02 10:50:47 +02:00
reuben olinsky
102a4467e1
Add support for string values with embedded '\0' characters (#137)
* Add support for strings with \0 chars

* address feedback

* Increments minor version, adds comments, changes license year

Co-authored-by: Krzysztof Gabis <kgabis@gmail.com>
2020-04-16 21:55:56 +02:00
Krzysztof Gabis
8d8850d9d5
Update README.md 2020-04-06 00:00:40 +02:00
Krzysztof Gabis
70dc239f8f Optional tests directory path argument in tests.c 2020-02-20 20:39:41 +01:00
ɹɐɯsǝʎ
186680a511 Guard against potential integer overflow (#133)
* Guard against potential integer overflow

If int res holds the value INT_MAX then adding 1 results in undefined
behavior. To guard against this possibility, cast res to size_t, not
the result of res + 1.

Fixes #132

* Increments version.

* More consitent parentheses when casting to size_t.
2019-12-03 10:59:32 +01:00
dan soucy
9d63e76014 Avoid truncating strings warning (#131)
* Avoid truncating strings warning

GCC 8 introduced the `stringop-truncation` warning, which warns for
uses of `strncpy` of the form `strncpy(out, in, strlen(in))`. This
is often helpful, as this call would not copy the trailing `\0`,
potentially leading to subtle bugs.

With optimizations enabled, the function `parson_strndup` is
inlined, allowing the compiler to see that this call to `strncpy` is
of the form described above. GCC therefore outputs the warning.

In this case, the out buffer has already had the terminating `\0`
written to the end. Thus it is not necessary to copy it. GCC 9.2 is
not quite smart enough to recognize this, so it warns.

The warning is silenced by using `memcpy` instead of `strncpy`.

Although I have not benchmarked it, this change might reasonably
improve the performance of `parson_strndup`. `strncpy` checks every
byte for `\0` in addition to counting to `n`. `memcpy` does not need
to check whether the bytes it copies are `\0`.

However, if `parson_strndup` is frequently passed `char *`s with a
`\0` somewhere in the middle, then `memcpy` will copy more bytes
than necessary, hurting performance. In this case, a better solution
might be:

```
- output_string[n] = `\0`;
- strncpy(output_string, string, n);
+ strncpy(output_string, string, n+1);
```

* Increments parson's version.
2019-12-02 23:24:29 +01:00
Krzysztof Gabis
0341880552 Using semantic versioning from now on, Parson is officially 1.0.0 2019-11-28 10:12:03 +01:00
Krzysztof Gabis
de7fbfac12
Merge pull request #124 from DasRoteSkelett/bugfix/locationCmakeConfigFilesOnInstall
CMakeLists.txt: Minimal fixes, added GNUInstallDirs and fixed cmake c…
2019-11-28 10:06:26 +01:00
Krzysztof Gabis
2be6991d84 Adds tests to avoid json_object_set_* memory leaks (fixed in 39c2d51). 2019-11-12 09:01:03 +01:00
Krzysztof Gabis
39c2d51c52
Merge pull request #128 from danellis/master
Fix memory leaks in `parson_object_set_*` when `object` is invalid
2019-11-12 08:57:48 +01:00
Dan Ellis
9e1de5086f Fix memory leaks in parson_object_set_* when object is invalid 2019-11-11 14:05:45 -08:00
Matthias Schoepfer
da126c2aba CMakeLists.txt: Minimal fixes, added GNUInstallDirs and fixed cmake config loc
Also set version for proper shared lib

Signed-off-by: Matthias Schoepfer <matthias.schoepfer@ithinx.io>
2019-08-14 18:19:51 +02:00
Krzysztof Gabis
c5bb9557fe Updates copyright year. 2019-07-11 18:33:44 +02:00
Krzysztof Gabis
409afcb437
Merge pull request #121 from AkihiroSuda/spdx
add SPDX-License-Identifier
2019-07-11 18:30:11 +02:00
Akihiro Suda
9ec77a8d74 add SPDX-License-Identifier
SPDX-License-Identifier is useful to clarify the license (both for humans and
machines), especially when the code of the project is embedded into other
projects.

ref: https://spdx.org/using-spdx-license-identifier

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2019-07-11 21:23:37 +09:00
Krzysztof Gabis
33e5519d0a
Merge pull request #120 from ewertons/master
Add CMakeLists.txt with install definitions
2019-05-14 08:47:55 +02:00
Ewerton Scaboro da Silva
74ea152aa7 Add CMakeLists.txt with install definitions 2019-05-07 17:52:46 +00:00
Krzysztof Gabis
809ef4b7d8
Update README.md 2019-04-03 20:13:40 +02:00
Krzysztof Gabis
2e2e36651d
Shamelesser plug 2019-04-03 20:12:42 +02:00
Krzysztof Gabis
395e70d85b
Shameless plug 2019-03-14 13:50:06 +01:00
Krzysztof Gabis
302fba9cbb Makes escaping slashes when serializing JSON optional (adds json_set_escape_slashes() function)
Issues #20 #34 #90
2018-11-26 20:12:16 +01:00
Krzysztof Gabis
0a1896939f
Merge pull request #105 from zolvarga/master
Remove trailing spaces
2018-09-06 23:44:19 +02:00
zolvarga
69684f600c Remove trailing spaces 2018-09-06 13:30:52 -07:00
Krzysztof Gabis
b58ac757a8 Using isnan and isinf macros if they are defined (fixes issue #104). 2018-08-02 21:20:39 +02:00
Krzysztof Gabis
4f3eaa6849 Not adding incorrect objects if json_object_dotset_value() fails halfway through.
Related to issue #100
2018-05-12 17:42:14 +02:00
Krzysztof Gabis
921da6f5d7 Using smaller buffer size for number serialization.
Issue #88 and #61
2018-04-15 17:39:56 +02:00
Krzysztof Gabis
387c5665f6 Better handling of CRLF line breaks. 2018-02-06 20:32:02 +01:00
Krzysztof Gabis
c147744b72 Workaround for MSVC C2124 error. 2018-01-04 18:41:43 +01:00
Krzysztof Gabis
bef4969d25
Merge pull request #91 from JetstreamRoySprowl/master
Fix signed char fed to isspace
2017-12-09 11:12:33 +01:00
Roy Sprowl
385b476a30 Fix signed char fed to isspace 2017-12-07 21:51:47 -08:00
Krzysztof Gabis
b87a27c15c
Merge pull request #89 from lunixoid/master
Fixed condition
2017-10-28 00:05:58 +01:00
Roman Kalashnikov
f1bb6e7fbe
Fixed condition 2017-10-28 01:23:15 +03:00
Krzysztof Gabis
e112626cb5 Create LICENSE file
issue #87
2017-10-11 18:50:31 +01:00
Krzysztof Gabis
243bccb51d Merge pull request #85 from tbeu/fix-typos
Fix typos
2017-10-02 08:01:45 +01:00
tbeu
1839d0de54 Fix typos 2017-10-02 08:47:53 +02:00
Krzysztof Gabis
4e8a901242 Changes float print format, removes array/object capacity limit, doesn't accept inf/nan numbers. 2017-09-16 16:07:43 +01:00
Krzysztof Gabis
e18751499d Adds a simple memory leak test. 2017-09-14 21:01:32 +01:00
Krzysztof Gabis
e1292a0e3c Small refactoring in parse_utf16 (+ tests) and typo fix in json_array_remove. 2017-09-14 10:00:24 +01:00
Krzysztof Gabis
578b25e590 Counting malloc and free calls to avoid memory leaks (#82). 2017-09-06 10:13:23 +01:00
Krzysztof Gabis
343fe13f17 Order of items in an array is preserved after removing an item.
Issue #81
2017-09-06 10:02:52 +01:00
Krzysztof Gabis
d485b068c7 Fixes a memory leak (issue #82). 2017-09-04 19:56:17 +01:00
Krzysztof Gabis
e410fc7c33 Increases MAX_NESTING of json objects/arrays to 2048.
Fixes #75
2017-05-08 19:55:29 +01:00