cJSON
[Ported from github.com/DaveGamble/cJSON] Fix: heap-use-after-free in merge_patch when patch is subtree of target (#1065)
Brought by drakestapleton
cJSON / .github / CONTRIBUTING.md
| 1 | Contribution Guidelines |
| 2 | ======================= |
| 3 | |
| 4 | Contributions to cJSON are welcome. If you find a bug or want to improve cJSON in another way, pull requests are appreciated. |
| 5 | |
| 6 | For bigger changes, in order to avoid wasted effort, please open an issue to discuss the technical details before creating a pull request. |
| 7 | |
| 8 | The further sections explain the process in more detail and provides some guidelines on how contributions should look like. |
| 9 | |
| 10 | Branches |
| 11 | -------- |
| 12 | There are two branches to be aware of, the `master` and the `develop` branch. The `master` branch is reserved for the latest release, so only make pull requests to the `master` branch for small bug- or security fixes (these are usually just a few lines). In all other cases, please make a pull request to the `develop` branch. |
| 13 | |
| 14 | Coding Style |
| 15 | ------------ |
| 16 | The coding style has been discussed in [#24](https://github.com/DaveGamble/cJSON/issues/24). The basics are: |
| 17 | |
| 18 | * Use 4 spaces for indentation |
| 19 | * No oneliners (conditions, loops, variable declarations ...) |
| 20 | * Always use parenthesis for control structures |
| 21 | * Don't implicitly rely on operator precedence, use round brackets in expressions. e.g. `(a > b) && (c < d)` instead of `a>b && c<d` |
| 22 | * opening curly braces start in the next line |
| 23 | * use spaces around operators |
| 24 | * lines should not have trailing whitespace |
| 25 | * use spaces between function parameters |
| 26 | * use pronouncable variable names, not just a combination of letters |
| 27 | |
| 28 | Example: |
| 29 | |
| 30 | ```c |
| 31 | /* calculate the new length of the string in a printbuffer and update the offset */ |
| 32 | static void update_offset(printbuffer * const buffer) |
| 33 | { |
| 34 | const unsigned char *buffer_pointer = NULL; |
| 35 | if ((buffer == NULL) || (buffer->buffer == NULL)) |
| 36 | { |
| 37 | return; |
| 38 | } |
| 39 | buffer_pointer = buffer->buffer + buffer->offset; |
| 40 | |
| 41 | buffer->offset += strlen((const char*)buffer_pointer); |
| 42 | } |
| 43 | ``` |
| 44 | |
| 45 | Unit Tests |
| 46 | ---------- |
| 47 | cJSON uses the [Unity](https://github.com/ThrowTheSwitch/Unity) library for unit tests. The tests are located in the `tests` directory. In order to add a new test, either add it to one of the existing files (if it fits) or add a new C file for the test. That new file has to be added to the list of tests in `tests/CMakeLists.txt`. |
| 48 | |
| 49 | All new features have to be covered by unit tests. |
| 50 | |
| 51 | Other Notes |
| 52 | ----------- |
| 53 | * Internal functions are to be declared static. |
| 54 | * Wrap the return type of external function in the `CJSON_PUBLIC` macro. |