From b58af2485fb6562f372dde7420472eb4f1382833 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Oct 30 2018 05:18:32 +0000 Subject: import libfastjson-0.99.4-3.el7 --- diff --git a/SOURCES/0001-Bug-1591493-add-support-for-array-item-deletion.patch b/SOURCES/0001-Bug-1591493-add-support-for-array-item-deletion.patch new file mode 100644 index 0000000..127fae8 --- /dev/null +++ b/SOURCES/0001-Bug-1591493-add-support-for-array-item-deletion.patch @@ -0,0 +1,100 @@ +From 51cf76acb55aa933212c9ac78176835e1b12c7e6 Mon Sep 17 00:00:00 2001 +From: Noriko Hosoi +Date: Fri, 25 May 2018 11:09:46 -0700 +Subject: [PATCH] Bug 1591493 - add support for array item deletion + +Adding "void fjson_object_array_del_idx(struct fjson_object *jso, int idx)", +which deletes the idx-th element in the array type object. + +(cherry picked from commit e32df78fc68a4ae881681b5f845967edd6b86004 -- https://github.com/rsyslog/libfastjson) +--- + arraylist.c | 16 ++++++++++++++++ + arraylist.h | 3 +++ + json_object.c | 8 ++++++++ + json_object.h | 3 +++ + 4 files changed, 30 insertions(+) + +diff --git a/arraylist.c b/arraylist.c +index 210b5c5..fc8dfe1 100644 +--- a/arraylist.c ++++ b/arraylist.c +@@ -87,6 +87,22 @@ array_list_add(struct array_list *arr, void *data) + return array_list_put_idx(arr, arr->length, data); + } + ++/* ++ * Deleting the idx-th element in the array_list. ++ */ ++void ++array_list_del_idx(struct array_list *const arr, const int idx) ++{ ++ if (idx < 0 || idx >= arr->length) { ++ return; ++ } ++ if(arr->array[idx]) arr->free_fn(arr->array[idx]); ++ if (--arr->length > idx) { ++ memmove(arr->array + idx, arr->array + idx + 1, (arr->length - idx) * sizeof(void *)); ++ } ++ return; ++} ++ + /* work around wrong compiler message: GCC and clang do + * not handle sort_fn correctly if -Werror is given. + */ +diff --git a/arraylist.h b/arraylist.h +index 4b0f9e8..54ddad4 100644 +--- a/arraylist.h ++++ b/arraylist.h +@@ -41,6 +41,9 @@ array_list_put_idx(struct array_list *al, int i, void *data); + extern int + array_list_add(struct array_list *al, void *data); + ++extern void ++array_list_del_idx(struct array_list *const arr, const int idx); ++ + extern int + array_list_length(struct array_list *al); + +diff --git a/json_object.c b/json_object.c +index 56e8df6..42e516f 100644 +--- a/json_object.c ++++ b/json_object.c +@@ -1053,6 +1053,14 @@ struct fjson_object* fjson_object_array_get_idx(struct fjson_object *jso, + return (struct fjson_object*)array_list_get_idx(jso->o.c_array, idx); + } + ++/* ++ * Deleting the idx-th element in the array type object. ++ */ ++void fjson_object_array_del_idx(struct fjson_object *jso, int idx) ++{ ++ array_list_del_idx(jso->o.c_array, idx); ++} ++ + int fjson_object_get_member_count(struct fjson_object *jso) + { + return jso->o.c_obj.nelem; +diff --git a/json_object.h b/json_object.h +index 55ee177..80a2075 100644 +--- a/json_object.h ++++ b/json_object.h +@@ -469,6 +469,8 @@ extern int fjson_object_array_put_idx(struct fjson_object *obj, int idx, + extern struct fjson_object* fjson_object_array_get_idx(struct fjson_object *obj, + int idx); + ++extern void fjson_object_array_del_idx(struct fjson_object *jso, int idx); ++ + /* fjson_bool type methods */ + + /** Create a new empty fjson_object of type fjson_type_boolean +@@ -720,6 +722,7 @@ typedef struct fjson_tokener fjson_tokener; + #define json_object_get_int64 fjson_object_get_int64 + #define json_object_get_string_len fjson_object_get_string_len + #define json_object_get_member_count fjson_object_get_member_count ++#define json_object_array_del_idx fjson_object_array_del_idx + + + #endif +-- +2.14.4 + diff --git a/SPECS/libfastjson.spec b/SPECS/libfastjson.spec index 84d8de6..a29bdad 100644 --- a/SPECS/libfastjson.spec +++ b/SPECS/libfastjson.spec @@ -1,6 +1,6 @@ Name: libfastjson Version: 0.99.4 -Release: 2%{?dist} +Release: 3%{?dist} Summary: A JSON implementation in C License: MIT URL: https://github.com/rsyslog/libfastjson @@ -8,6 +8,7 @@ Source0: http://download.rsyslog.com/libfastjson/libfastjson-%{version}.tar.gz # 1421612 - New defect found in libfastjson-0.99.4-1.el7 Patch0: libfastjson-0.99.4-rhbz1421612-nullptr-guard.patch +Patch1: 0001-Bug-1591493-add-support-for-array-item-deletion.patch %description LIBFASTJSON implements a reference counting object @@ -28,6 +29,7 @@ developing applications that use libfastjson. %prep %setup -q %patch0 -p1 +%patch1 -p1 for doc in ChangeLog; do iconv -f iso-8859-1 -t utf8 $doc > $doc.new && @@ -62,6 +64,9 @@ make V=1 check %{_libdir}/pkgconfig/libfastjson.pc %changelog +* Fri Jun 22 2018 Noriko Hosoi - 0.99.4-3 + Resolves: #1591493 - add support for array item deletion + * Tue Mar 07 2017 Daniel Kopecek - 0.99.4-2 - Fix defect found by clang-analyzer Resolves: #1421612