summaryrefslogtreecommitdiff
path: root/arraylist.c
Commit message (Collapse)AuthorAgeFilesLines
* Validate size arguments in arraylist functions.Tobias Stoeckmann2020-08-241-0/+4
| | | | | | | | | | | | | | | | | The array_list_new2 function, which is externally reachable through json_object_new_array_ext, does not check if specified initial size actually fits into memory on 32 bit architectures. It also allows negative values, which could lead to an overflow on these architectures as well. I have added test cases for these situations. While at it, also protect array_list_shrink against too large empty_slots argument. No test added because it takes a huge length value, therefore a lot of items within the array, to overflow the calculation. In theory this affects 64 bit sytems as well, but since the arraylist API is not supposed to be used by external applications according to its header file, the call is protected due to int limitation of json_object_array_shrink.
* Add json_object_array_shrink() (and array_list_shrink()) and use it in ↵Eric Haszlakiewicz2020-06-201-1/+28
| | | | | | json_tokener to minimize the amount of memory used. This results in a 39%-50% reduction in memory use (peak RSS, peak heap usage) on the jc-bench benchmark and 9% shorter runtime. Also add the json_object_new_array_ext, array_list_new2, and array_list_shrink functions.
* In arraylist, use malloc instead of calloc, avoid clearing with memeset ↵Eric Haszlakiewicz2020-05-241-4/+25
| | | | until we really need to, and micro-optimize array_list_add().
* Protect array_list_del_idx against size_t overflow.Tobias Stoeckmann2020-05-041-0/+3
| | | | | | | | | If the assignment of stop overflows due to idx and count being larger than SIZE_T_MAX in sum, out of boundary access could happen. It takes invalid usage of this function for this to happen, but I decided to add this check so array_list_del_idx is as safe against bad usage as the other arraylist functions.
* clang-format the filesdota172020-04-031-75/+79
|
* Changed order of calloc args to match stdlib (2)Robert2020-04-021-1/+1
| | | Although it is currently working, it's worth to stick with the stdlib definition to avoid further problems
* arraylist: Fix names of parameters for callback functionmax2018-06-011-4/+4
|
* Issue #351: don't redefine SIZE_T_MAX if it's already defined.Eric Haszlakiewicz2017-08-301-0/+2
|
* Issue #332: fix a long-standing bug in array_list_put_idx() where it would ↵Eric Haszlakiewicz2017-07-081-1/+2
| | | | | | attempt to free previously free'd entries due to not checking the current array length. Add a test that triggers the problem to ensure it stays fixed.
* Issue #295: also check if size_t is the size of long long, to help support ↵Eric Haszlakiewicz2017-01-071-0/+2
| | | | 64-bit Windows platforms.
* Fix a few places that needed adjustment for the size_t changes, including ↵Eric Haszlakiewicz2016-05-231-7/+15
| | | | updating the range checks to use a calculated SIZE_T_MAX.
* Merge branch 'fixes-for-upstream' of https://github.com/doctaweeks/json-c ↵Eric Haszlakiewicz2016-05-231-6/+6
|\ | | | | | | into doctaweeks-fixes-for-upstream
| * Use size_t for array list length and sizeDaniel M. Weeks2015-11-241-6/+6
| |
* | Merge branch 'master' of https://github.com/Protovision/json-c into ↵Eric Haszlakiewicz2016-04-301-0/+15
|\ \ | | | | | | | | | Protovision-master
| * | Added array_list_del_idx and json_object_array_del_idxMark Swoope2015-04-021-0/+15
| |/
* | Fix various potential null ptr deref and int32 overflowsEven Rouault2016-01-111-3/+13
|/ | | | | This fix errors that can happen when ingesting very large JSON files when hitting the maximum heap size of the process.
* Slight style tweaks to the bsearch changest.Eric Haszlakiewicz2015-03-041-4/+4
|
* add bsearch for arraysAlexander Dahl2014-08-211-2/+8
| | | | | | Arrays can already be sorted with json_object_array_sort() which uses qsort() of the standard C library. This adds a counterpart using the bsearch() from C.
* Move the json_min() and json_max() macros to json_util.h and mark everything ↵Eric Haszlakiewicz2014-05-041-2/+3
| | | | | | else in bits.h deprecated. Eliminate all uses of bits.h within the json-c code.
* Merge pull request #27 from OBI-1/masterEric Haszlakiewicz2012-05-301-1/+1
|\ | | | | array_list_expand_internal needs length, not index.
| * array_list_expand_internal needs length, not index. OBI-12012-05-091-1/+1
| | | | | | (The current implementation will fail when adding index 65.)
* | Replaced #if HAVE_X with #ifdef HAVE_X as the former test is troublemaker ↵Mateusz Loskot2012-05-211-2/+2
|/ | | | with #define HAVE_X where #define HAVE_X 1|0 is meant.
* Add new json_object_array_sort functionFrederik Deweerdt2011-10-071-0/+7
| | | | | - uses libc's qsort to sort the arraylist - add test in test1.c
* * Rename min and max so we can never clash with C or C++ std libraryMichael Clark2009-07-251-1/+1
| | | | | | | | Ian Atha, thatha at yahoo-inc dot com git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@43 327403b1-1117-474d-bef2-5cb71233fd97
* * Don't use this as a variable, so we can compile with a C++ compilerMichael Clark2009-02-251-3/+4
| | | | | | | | | | * Add casts from void* to type of assignment when using malloc * Add #ifdef __cplusplus guards to all of the headers * Add typedefs for json_object, json_tokener, array_list, printbuf, lh_table Michael Clark, <michael@metaparadigm.com> git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@33 327403b1-1117-474d-bef2-5cb71233fd97
* * Don't use this as a variable, so we can compile with a C++ compilerMichael Clark2009-02-251-32/+32
| | | | | | | Michael Clark, <michael@metaparadigm.com> git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@32 327403b1-1117-474d-bef2-5cb71233fd97
* * Null pointer dereference fix. Fix json_object_get_boolean strlen testMichael Clark2009-02-251-1/+1
| | | | | | | | to not return TRUE for zero length string. Remove redundant includes. Erik Hovland, erik at hovland dot org git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@31 327403b1-1117-474d-bef2-5cb71233fd97
* * Make headers C++ compatible by change *this to *objMichael Clark2007-03-131-11/+4
| | | | | | | | | | | | | | | * Add ifdef C++ extern "C" to headers * Use simpler definition of min and max in bits.h Larry Lansing, llansing at fuzzynerd dot com * Remove automake 1.6 requirement * Move autogen commands into autogen.sh. Update README * Remove error pointer special case for Windows * Change license from LGPL to MIT Michael Clark <michael@metaparadigm.com> git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@10 327403b1-1117-474d-bef2-5cb71233fd97
* * printbuf.c - C. Watford (christopher dot watford at gmail dot com)Michael Clark2007-03-131-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | Added a Win32/Win64 compliant implementation of vasprintf * debug.c - C. Watford (christopher dot watford at gmail dot com) Removed usage of vsyslog on Win32/Win64 systems, needs to be handled by a configure script * json_object.c - C. Watford (christopher dot watford at gmail dot com) Added scope operator to wrap usage of json_object_object_foreach, this needs to be rethought to be more ANSI C friendly * json_object.h - C. Watford (christopher dot watford at gmail dot com) Added Microsoft C friendly version of json_object_object_foreach * json_tokener.c - C. Watford (christopher dot watford at gmail dot com) Added a Win32/Win64 compliant implementation of strndup * json_util.c - C. Watford (christopher dot watford at gmail dot com) Added cast and mask to suffice size_t v. unsigned int conversion correctness * json_tokener.c - sign reversal issue on error info for nested object parse spotted by Johan Bj�rklund (johbjo09 at kth.se) * json_object.c - escape " in json_escape_str * Change to automake and libtool to build shared and static library Michael Clark <michael@metaparadigm.com> git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@4 327403b1-1117-474d-bef2-5cb71233fd97
* import of version 0.1Michael Clark2007-03-131-0/+94
git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@2 327403b1-1117-474d-bef2-5cb71233fd97