Hello community, here is the log from the commit of package libcomps for openSUSE:Factory checked in at 2019-02-20 14:10:00 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libcomps (Old) and /work/SRC/openSUSE:Factory/.libcomps.new.28833 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libcomps" Wed Feb 20 14:10:00 2019 rev:3 rq:672448 version:0.1.9 Changes: -------- --- /work/SRC/openSUSE:Factory/libcomps/libcomps.changes 2017-09-20 17:07:32.257081251 +0200 +++ /work/SRC/openSUSE:Factory/.libcomps.new.28833/libcomps.changes 2019-02-20 14:10:06.150964005 +0100 @@ -2 +2,14 @@ -Sun Sep 17 19:12:56 UTC 2017 - [email protected] +Sun Feb 3 19:07:56 UTC 2019 - Neal Gompa <[email protected]> + +- Upgrade to 0.1.9 + + Fix memory leaks + + Remove unused code +- Backport fix for logic error + * Patch: 0001-Fix-Missing-braces.patch +- Backport fix for CVE-2019-3817 (boo#1122841) + * Patch: 0002-Fix-UAF-in-comps_objmrtree_unite-function.patch +- Drop Python 2 subpackage +- Adjust changes entries to use full author identities + +------------------------------------------------------------------- +Sun Sep 17 19:12:56 UTC 2017 - Bernhard Wiedemann <[email protected]> @@ -7 +20 @@ -Sun Aug 13 19:12:57 UTC 2017 - [email protected] +Sun Aug 13 19:12:57 UTC 2017 - Neal Gompa <[email protected]> @@ -12 +25 @@ -Mon Feb 1 06:43:39 UTC 2016 - [email protected] +Mon Feb 1 06:43:39 UTC 2016 - Neal Gompa <[email protected]> Old: ---- libcomps-0.1.8.tar.gz New: ---- 0001-Fix-Missing-braces.patch 0002-Fix-UAF-in-comps_objmrtree_unite-function.patch libcomps-0.1.9.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libcomps.spec ++++++ --- /var/tmp/diff_new_pack.zzZG8Y/_old 2019-02-20 14:10:07.334963611 +0100 +++ /var/tmp/diff_new_pack.zzZG8Y/_new 2019-02-20 14:10:07.334963611 +0100 @@ -1,7 +1,8 @@ # # spec file for package libcomps # -# Copyright (c) 2017 Neal Gompa <[email protected]>. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 Neal Gompa <[email protected]>. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,27 +17,30 @@ # -%bcond_without python3 - %define major 0 %define minor 1 -%define patch 6 +%define patch 9 %define libname %{name}%{major}_%{minor}_%{patch} %define devname %{name}-devel -%{!?python2_sitearch: %global python2_sitearch %{python_sitearch}} - Name: libcomps -Version: 0.1.8 +Version: %{major}.%{minor}.%{patch} Release: 0 Summary: Comps XML file manipulation library -License: GPL-2.0+ +License: GPL-2.0-or-later Group: System/Libraries Url: https://github.com/rpm-software-management/libcomps Source0: %{url}/archive/%{name}-%{version}/%{name}-%{version}.tar.gz -# PATCH-FIX-OPENSUSE libcomps-0.1.7-Add-zlib-as-an-explicit-dependency.patch [email protected] -- Fixes zlib linking issues +# Patches from upstream +# Fix missing braces +Patch0001: 0001-Fix-Missing-braces.patch +# Fix use after free in comps_objmrtree_unite() - CVE-2019-3817 - boo#1122841 - rh#1668005 +Patch0002: 0002-Fix-UAF-in-comps_objmrtree_unite-function.patch + +# openSUSE specific fixes +# Fix zlib linking issues Patch1000: libcomps-0.1.7-Add-zlib-as-an-explicit-dependency.patch BuildRequires: check-devel @@ -46,9 +50,10 @@ BuildRequires: libexpat-devel BuildRequires: libxml2-devel BuildRequires: zlib-devel +BuildRequires: python-rpm-macros # prevent provides from nonstandard paths: -%define __provides_exclude ^(%{python2_sitearch}/.*\\.so\\|%{python3_sitearch}/.*\\.so)$ +%define __provides_exclude ^(%{python3_sitearch}/.*\\.so)$ %description Libcomps is library for structure-like manipulation with content of @@ -68,87 +73,55 @@ Requires: pkg-config %description -n %{devname} -Development files for %{name}. +This package provides the development files for %{name}. %package doc Summary: Documentation files for libcomps library -Group: Documentation +Group: Documentation/HTML BuildArch: noarch BuildRequires: doxygen %description doc -Documentation files for libcomps library +Documentation files for libcomps library. %package -n python-libcomps-doc Summary: Documentation files for python bindings libcomps library -Group: Documentation +Group: Documentation/HTML BuildArch: noarch -BuildRequires: python-Sphinx +BuildRequires: python3-Sphinx %description -n python-libcomps-doc -Documentation files for python bindings libcomps library - -%package -n python2-libcomps -Summary: Python 2 bindings for libcomps library -Group: Development/Libraries/Python -BuildRequires: python-devel -Provides: python-%{name} = %{version}-%{release} -Requires: %{libname}%{?_isa} = %{version}-%{release} - -%description -n python2-libcomps -Python2 bindings for libcomps library +Documentation files for python bindings libcomps library. -%if %{with python3} %package -n python3-libcomps Summary: Python 3 bindings for libcomps library Group: Development/Libraries/Python BuildRequires: python3-devel Requires: %{libname}%{?_isa} = %{version}-%{release} +# There is no more Python 2 subpackage +Obsoletes: python2-libcomps < 0.1.9 %description -n python3-libcomps -Python3 bindings for libcomps library -%endif +This package provides the Python 3 bindings for libcomps library. %prep %autosetup -n %{name}-%{name}-%{version} -p1 -%if %{with python3} -rm -rf py3 -mkdir py3 -%endif - %build -%cmake -DPYTHON_DESIRED:STRING=2 ../libcomps/ -make %{?_smp_mflags} +%cmake -DPYTHON_DESIRED:STRING=3 ../libcomps/ +%make_build make docs make pydocs -%if %{with python3} -pushd ../py3 -%cmake -DPYTHON_DESIRED:STRING=3 ../../libcomps/ -make %{?_smp_mflags} -popd -%endif - %check pushd ./build make test popd -%if %{with python3} -pushd ./py3/build -make pytest -popd -%endif %install pushd ./build %make_install popd -%if %{with python3} -pushd ./py3/build -%make_install -popd -%endif mkdir -p %{buildroot}%{_datadir}/doc/libcomps/ cp -a build/docs/libcomps-doc/html %{buildroot}%{_datadir}/doc/libcomps/ @@ -178,12 +151,7 @@ %files -n python-libcomps-doc %doc %{_datadir}/doc/python-libcomps -%files -n python2-libcomps -%{python2_sitearch}/libcomps - -%if %{with python3} %files -n python3-libcomps %{python3_sitearch}/libcomps -%endif %changelog ++++++ 0001-Fix-Missing-braces.patch ++++++ >From c6d5e6e7f220ee5e3cdccc440c03119e3ce411d3 Mon Sep 17 00:00:00 2001 From: Jaroslav Rohel <[email protected]> Date: Thu, 13 Dec 2018 15:12:30 +0100 Subject: [PATCH 1/2] Fix: Missing braces --- libcomps/tests/check_objrtree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libcomps/tests/check_objrtree.c b/libcomps/tests/check_objrtree.c index bdb3f0e..c0546f2 100644 --- a/libcomps/tests/check_objrtree.c +++ b/libcomps/tests/check_objrtree.c @@ -60,9 +60,10 @@ COMPS_ObjRTree * load_acrodict(char *filename) { } while (!feof(f)) { memset(buffer, 0, 100); - if (!fgets(buffer, 100, f)) + if (!fgets(buffer, 100, f)) { fclose(f); return rt; + } buffer[strlen(buffer)-1] =0; //printf("buffer:%s\n", buffer); pch = strrchr(buffer, '-'); -- 2.20.1 ++++++ 0002-Fix-UAF-in-comps_objmrtree_unite-function.patch ++++++ >From e3a5d056633677959ad924a51758876d415e7046 Mon Sep 17 00:00:00 2001 From: Riccardo Schirone <[email protected]> Date: Mon, 21 Jan 2019 18:11:42 +0100 Subject: [PATCH 2/2] Fix UAF in comps_objmrtree_unite function The added field is not used at all in many places and it is probably the left-over of some copy-paste. --- libcomps/src/comps_mradix.c | 2 -- libcomps/src/comps_objmradix.c | 2 -- libcomps/src/comps_objradix.c | 2 -- libcomps/src/comps_radix.c | 1 - 4 files changed, 7 deletions(-) diff --git a/libcomps/src/comps_mradix.c b/libcomps/src/comps_mradix.c index 8ef9640..dfdee8e 100644 --- a/libcomps/src/comps_mradix.c +++ b/libcomps/src/comps_mradix.c @@ -177,7 +177,6 @@ void comps_mrtree_unite(COMPS_MRTree *rt1, COMPS_MRTree *rt2) { struct Pair { COMPS_HSList * subnodes; char * key; - char added; } *pair, *parent_pair; pair = malloc(sizeof(struct Pair)); @@ -195,7 +194,6 @@ void comps_mrtree_unite(COMPS_MRTree *rt1, COMPS_MRTree *rt2) { parent_pair = (struct Pair*) it->data; free(it); - pair->added = 0; for (it = tmp_subnodes->first; it != NULL; it=it->next) { pair = malloc(sizeof(struct Pair)); pair->subnodes = ((COMPS_MRTreeData*)it->data)->subnodes; diff --git a/libcomps/src/comps_objmradix.c b/libcomps/src/comps_objmradix.c index 9a2038b..22ad262 100644 --- a/libcomps/src/comps_objmradix.c +++ b/libcomps/src/comps_objmradix.c @@ -285,7 +285,6 @@ void comps_objmrtree_unite(COMPS_ObjMRTree *rt1, COMPS_ObjMRTree *rt2) { struct Pair { COMPS_HSList * subnodes; char * key; - char added; } *pair, *parent_pair; pair = malloc(sizeof(struct Pair)); @@ -303,7 +302,6 @@ void comps_objmrtree_unite(COMPS_ObjMRTree *rt1, COMPS_ObjMRTree *rt2) { parent_pair = (struct Pair*) it->data; free(it); - pair->added = 0; for (it = tmp_subnodes->first; it != NULL; it=it->next) { pair = malloc(sizeof(struct Pair)); pair->subnodes = ((COMPS_ObjMRTreeData*)it->data)->subnodes; diff --git a/libcomps/src/comps_objradix.c b/libcomps/src/comps_objradix.c index c657b75..840592a 100644 --- a/libcomps/src/comps_objradix.c +++ b/libcomps/src/comps_objradix.c @@ -697,7 +697,6 @@ void comps_objrtree_unite(COMPS_ObjRTree *rt1, COMPS_ObjRTree *rt2) { struct Pair { COMPS_HSList * subnodes; char * key; - char added; } *pair, *parent_pair; pair = malloc(sizeof(struct Pair)); @@ -716,7 +715,6 @@ void comps_objrtree_unite(COMPS_ObjRTree *rt1, COMPS_ObjRTree *rt2) { //printf("key-part:%s\n", parent_pair->key); free(it); - //pair->added = 0; for (it = tmp_subnodes->first; it != NULL; it=it->next) { pair = malloc(sizeof(struct Pair)); pair->subnodes = ((COMPS_ObjRTreeData*)it->data)->subnodes; diff --git a/libcomps/src/comps_radix.c b/libcomps/src/comps_radix.c index ada4fda..05dcaf2 100644 --- a/libcomps/src/comps_radix.c +++ b/libcomps/src/comps_radix.c @@ -529,7 +529,6 @@ void comps_rtree_unite(COMPS_RTree *rt1, COMPS_RTree *rt2) { struct Pair { COMPS_HSList * subnodes; char * key; - char added; } *pair, *parent_pair; pair = malloc(sizeof(struct Pair)); -- 2.20.1 ++++++ libcomps-0.1.8.tar.gz -> libcomps-0.1.9.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/src/comps_bradix.c new/libcomps-libcomps-0.1.9/libcomps/src/comps_bradix.c --- old/libcomps-libcomps-0.1.8/libcomps/src/comps_bradix.c 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/src/comps_bradix.c 2018-12-12 13:36:35.000000000 +0100 @@ -40,7 +40,10 @@ if ((brtd = malloc(sizeof(COMPS_BRTreeData))) == NULL) return NULL; brtd->key = brt->key_clone(key, keylen); - if (!brtd->key) return NULL; + if (!brtd->key) { + free(brtd); + return NULL; + } brtd->data = data; if (data != NULL) { @@ -305,7 +308,6 @@ it->next = NULL; ((COMPS_BRTreeData*)subnodes->last->data)->subnodes->last->next = it; ((COMPS_BRTreeData*)subnodes->last->data)->subnodes->last = it; - len = brt->key_len(brtdata->key)-x; newkey = brt->subkey(brtdata->key, x, brt->key_len(brtdata->key)); brt->key_destroy(brtdata->key); brtdata->key = newkey; @@ -415,8 +417,10 @@ break; } } - if (!found) + if (!found) { + comps_hslist_destroy(&path); return; + } brtdata = (COMPS_BRTreeData*)it->data; x = brt->key_cmp(brtdata->key, key, 1, offset+1, len, &ended); if (ended == 3) { @@ -459,7 +463,10 @@ return; } else if (ended == 1) offset+=x; - else return; + else { + comps_hslist_destroy(&path); + return; + } if ((relation = malloc(sizeof(struct Relation))) == NULL) { comps_hslist_destroy(&path); return; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/src/comps_doc.c new/libcomps-libcomps-0.1.9/libcomps/src/comps_doc.c --- old/libcomps-libcomps-0.1.8/libcomps/src/comps_doc.c 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/src/comps_doc.c 2018-12-12 13:36:35.000000000 +0100 @@ -734,7 +734,6 @@ if (mdict && mdict->len) { retc = xmlTextWriterStartElement(writer, BAD_CAST "blacklist"); if (__comps_check_xml_get(retc, (COMPS_Object*)doc->log) < 0) { - COMPS_OBJECT_DESTROY(dict); return -1; } hslist = comps_objmrtree_pairs(mdict); @@ -744,7 +743,6 @@ it != NULL; it = it->next) { retc = xmlTextWriterStartElement(writer, BAD_CAST "package"); if (__comps_check_xml_get(retc, (COMPS_Object*)doc->log) < 0) { - COMPS_OBJECT_DESTROY(dict); comps_hslist_destroy(&hslist); return -1; } @@ -757,7 +755,6 @@ retc = xmlTextWriterEndElement(writer); if (__comps_check_xml_get(retc, (COMPS_Object*)doc->log) < 0) { - COMPS_OBJECT_DESTROY(dict); comps_hslist_destroy(&hslist); return -1; } @@ -767,7 +764,6 @@ retc = xmlTextWriterEndElement(writer); if (__comps_check_xml_get(retc, (COMPS_Object*)doc->log) < 0) { - COMPS_OBJECT_DESTROY(dict); return -1; } } @@ -786,7 +782,6 @@ it != NULL; it = it->next) { retc = xmlTextWriterStartElement(writer, BAD_CAST "ignoredep"); if (__comps_check_xml_get(retc, (COMPS_Object*)doc->log) < 0) { - COMPS_OBJECT_DESTROY(dict); comps_hslist_destroy(&hslist); return -1; } @@ -800,7 +795,6 @@ retc = xmlTextWriterEndElement(writer); if (__comps_check_xml_get(retc, (COMPS_Object*)doc->log) < 0) { - COMPS_OBJECT_DESTROY(dict); comps_hslist_destroy(&hslist); return -1; } @@ -810,7 +804,6 @@ retc = xmlTextWriterEndElement(writer); if (__comps_check_xml_get(retc, (COMPS_Object*)doc->log) < 0) { - COMPS_OBJECT_DESTROY(dict); return -1; } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/src/comps_doccategory.c new/libcomps-libcomps-0.1.9/libcomps/src/comps_doccategory.c --- old/libcomps-libcomps-0.1.8/libcomps/src/comps_doccategory.c 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/src/comps_doccategory.c 2018-12-12 13:36:35.000000000 +0100 @@ -230,12 +230,12 @@ return 1; } ret = xmlTextWriterStartElement(writer, BAD_CAST "category"); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() if (xml_options->arch_output) { obj = (COMPS_Object*)comps_doccategory_arches(category); ret = __comps_xml_arch(obj, writer); COMPS_OBJECT_DESTROY(obj); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() } for (int i=0; i<6; i++) { if (!type[i]) { @@ -281,16 +281,16 @@ } if (category->group_ids->len || xml_options->empty_grouplist) { ret = xmlTextWriterStartElement(writer, (xmlChar*)"grouplist"); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() for (it = category->group_ids->first; it != NULL; it = it->next) { comps_docgroupid_xml((COMPS_DocGroupId*)(COMPS_DocGroupId*)it->comps_obj, writer, log, xml_options, def_options); } ret = xmlTextWriterEndElement(writer); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() } ret = xmlTextWriterEndElement(writer); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() return 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/src/comps_docenv.c new/libcomps-libcomps-0.1.9/libcomps/src/comps_docenv.c --- old/libcomps-libcomps-0.1.8/libcomps/src/comps_docenv.c 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/src/comps_docenv.c 2018-12-12 13:36:35.000000000 +0100 @@ -204,7 +204,7 @@ if ((data = comps_set_data_at(set, (void*)it->comps_obj)) != NULL) { index = comps_objlist_index(res->option_list, (COMPS_Object*)data); comps_objlist_remove_at(res->option_list, index); - ret = comps_objlist_insert_at_x(res->option_list, index, + comps_objlist_insert_at_x(res->option_list, index, comps_object_copy(it->comps_obj)); } else { comps_docenv_add_optionid(res, (COMPS_DocGroupId*) @@ -314,11 +314,11 @@ return 1; } ret = xmlTextWriterStartElement(writer, BAD_CAST "environment"); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() if (xml_options->arch_output) { obj = (COMPS_Object*)comps_docenv_arches(env); ret = __comps_xml_arch(obj, writer); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() COMPS_OBJECT_DESTROY(obj); } for (int i=0; i<6; i++) { @@ -365,27 +365,27 @@ } if (env->group_list->len || xml_options->empty_grouplist) { ret = xmlTextWriterStartElement(writer, (xmlChar*)"grouplist"); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() for (it = env->group_list->first; it != NULL; it = it->next) { comps_docgroupid_xml((COMPS_DocGroupId*)(COMPS_DocGroupId*)it->comps_obj, writer, log, xml_options, def_options); } ret = xmlTextWriterEndElement(writer); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() } if (env->option_list->len || xml_options->empty_optionlist) { ret = xmlTextWriterStartElement(writer, (xmlChar*)"optionlist"); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() for (it = env->option_list->first; it != NULL; it = it->next) { comps_docgroupid_xml((COMPS_DocGroupId*)(COMPS_DocGroupId*)it->comps_obj, writer, log, xml_options, def_options); } ret = xmlTextWriterEndElement(writer); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() } ret = xmlTextWriterEndElement(writer); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() return 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/src/comps_docgroup.c new/libcomps-libcomps-0.1.9/libcomps/src/comps_docgroup.c --- old/libcomps-libcomps-0.1.8/libcomps/src/comps_docgroup.c 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/src/comps_docgroup.c 2018-12-12 13:36:35.000000000 +0100 @@ -305,11 +305,11 @@ return 1; } ret = xmlTextWriterStartElement(writer, BAD_CAST "group"); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() if (xml_options->arch_output) { obj = (COMPS_Object*)comps_docgroup_arches(group); ret = __comps_xml_arch(obj, writer); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() COMPS_OBJECT_DESTROY(obj); } for (int i=0; i<10; i++) { @@ -344,33 +344,33 @@ for (hsit = pairlist->first; hsit != NULL; hsit = hsit->next) { ret = xmlTextWriterStartElement(writer, (const xmlChar*)((aliases[i])?aliases[i]:props[i])); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK(comps_hslist_destroy(&pairlist)) ret = xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang", (xmlChar*) ((COMPS_ObjRTreePair*)hsit->data)->key); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK(comps_hslist_destroy(&pairlist)) str = tostrf[i](((COMPS_ObjRTreePair*)hsit->data)->data); ret = xmlTextWriterWriteString(writer, (xmlChar*)str); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK(comps_hslist_destroy(&pairlist)) free(str); ret = xmlTextWriterEndElement(writer); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK(comps_hslist_destroy(&pairlist)) } comps_hslist_destroy(&pairlist); } } if (group->packages->len || xml_options->empty_packages) { ret = xmlTextWriterStartElement(writer, (xmlChar*)"packagelist"); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() for (it = group->packages->first; it != NULL; it = it->next) { comps_docpackage_xml((COMPS_DocGroupPackage*)it->comps_obj, writer, log, xml_options, def_options); } ret = xmlTextWriterEndElement(writer); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() } ret = xmlTextWriterEndElement(writer); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() return 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/src/comps_docgroupid.c new/libcomps-libcomps-0.1.9/libcomps/src/comps_docgroupid.c --- old/libcomps-libcomps-0.1.8/libcomps/src/comps_docgroupid.c 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/src/comps_docgroupid.c 2018-12-12 13:36:35.000000000 +0100 @@ -109,13 +109,13 @@ (void)def_options; ret = xmlTextWriterStartElement(writer, BAD_CAST "groupid"); + COMPS_XMLRET_CHECK() if (options->arch_output) { COMPS_Object *obj = (COMPS_Object*)groupid->arches; //printf("obj %d\n", obj); ret = __comps_xml_arch(obj, writer); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() } - COMPS_XMLRET_CHECK if (options->gid_default_explicit) { if (groupid->def) ret = xmlTextWriterWriteAttribute(writer, BAD_CAST "default", @@ -123,7 +123,7 @@ else ret = xmlTextWriterWriteAttribute(writer, BAD_CAST "default", BAD_CAST "false"); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() } else if (groupid->def != default_def) { if (groupid->def) ret = xmlTextWriterWriteAttribute(writer, BAD_CAST "default", @@ -134,10 +134,10 @@ } str = comps_object_tostr((COMPS_Object*)groupid->name); ret = xmlTextWriterWriteString(writer, BAD_CAST str); - COMPS_XMLRET_CHECK free(str); + COMPS_XMLRET_CHECK() ret = xmlTextWriterEndElement(writer); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() return 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/src/comps_docpackage.c new/libcomps-libcomps-0.1.9/libcomps/src/comps_docpackage.c --- old/libcomps-libcomps-0.1.8/libcomps/src/comps_docpackage.c 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/src/comps_docpackage.c 2018-12-12 13:36:35.000000000 +0100 @@ -150,11 +150,11 @@ (void)def_options; ret = xmlTextWriterStartElement(writer, BAD_CAST "packagereq"); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() if (xml_options->arch_output) { COMPS_Object *obj = (COMPS_Object*)pkg->arches; ret = __comps_xml_arch(obj, writer); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() } if (pkg->type == COMPS_PACKAGE_OPTIONAL) str = "optional"; @@ -172,7 +172,7 @@ BAD_CAST str); free(str); } - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() if (xml_options->bao_explicit) { if (pkg->basearchonly) { ret = xmlTextWriterWriteAttribute(writer, (xmlChar*) "basearchonly", @@ -192,13 +192,13 @@ } } } - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() str = comps_object_tostr((COMPS_Object*)pkg->name); ret = xmlTextWriterWriteString(writer, (xmlChar*)str); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() free(str); ret = xmlTextWriterEndElement(writer); - COMPS_XMLRET_CHECK + COMPS_XMLRET_CHECK() return 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/src/comps_elem.c new/libcomps-libcomps-0.1.9/libcomps/src/comps_elem.c --- old/libcomps-libcomps-0.1.8/libcomps/src/comps_elem.c 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/src/comps_elem.c 2018-12-12 13:36:35.000000000 +0100 @@ -915,7 +915,12 @@ if (attrs != NULL) { for (; *attrs != NULL; attrs += 2) { val = malloc((strlen(*(attrs+1))+1)*sizeof(char)); - if (val == NULL) return NULL; + if (val == NULL) { + comps_dict_destroy(elem->attrs); + free(elem->name); + free(elem); + return NULL; + } memcpy(val, *(attrs+1), sizeof(char) * (strlen(*(attrs+1))+1)); comps_dict_set(elem->attrs, (char*)*attrs, val); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/src/comps_hslist.c new/libcomps-libcomps-0.1.9/libcomps/src/comps_hslist.c --- old/libcomps-libcomps-0.1.8/libcomps/src/comps_hslist.c 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/src/comps_hslist.c 2018-12-12 13:36:35.000000000 +0100 @@ -71,7 +71,7 @@ COMPS_HSListItem * it; void * ndata; - if (hslist == NULL && item == NULL) + if (hslist == NULL || item == NULL) return; if ((it = malloc(sizeof(*it))) == NULL) return; @@ -206,6 +206,7 @@ void comps_hslist_remove(COMPS_HSList * hslist, COMPS_HSListItem * it) { COMPS_HSListItem *itx, *itprev=NULL; + if (it == NULL) return; for (itx = hslist->first; itx != NULL && itx != it; itx = itx->next) { itprev = itx; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/src/comps_mradix.c new/libcomps-libcomps-0.1.9/libcomps/src/comps_mradix.c --- old/libcomps-libcomps-0.1.8/libcomps/src/comps_mradix.c 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/src/comps_mradix.c 2018-12-12 13:36:35.000000000 +0100 @@ -532,8 +532,10 @@ break; } } - if (!found) + if (!found) { + comps_hslist_destroy(&path); return; + } rtdata = (COMPS_MRTreeData*)it->data; for (x=1; ;x++) { @@ -582,7 +584,10 @@ return; } else if (ended == 1) offset+=x; - else return; + else { + comps_hslist_destroy(&path); + return; + } if ((relation = malloc(sizeof(struct Relation))) == NULL) { comps_hslist_destroy(&path); return; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/src/comps_objlist.c new/libcomps-libcomps-0.1.9/libcomps/src/comps_objlist.c --- old/libcomps-libcomps-0.1.8/libcomps/src/comps_objlist.c 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/src/comps_objlist.c 2018-12-12 13:36:35.000000000 +0100 @@ -58,10 +58,8 @@ COMPS_ObjListIt *oldit, *it = objlist->first; COMPS_Object **obj= NULL; - oldit = it; - for (; comps_objlist_walk(&it, obj); oldit = it) { + for (oldit = it; comps_objlist_walk(&it, obj); oldit = it) { comps_objlist_it_destroy(oldit); - oldit = it; } if (oldit) comps_objlist_it_destroy(oldit); @@ -143,7 +141,7 @@ } static int __comps_objlist_append(COMPS_ObjList *objlist, COMPS_ObjListIt *objit) { - if (!objlist) return 0; + if (!objlist || !objit) return 0; if (objlist->first == NULL) { objlist->first = objit; objlist->last = objit; @@ -215,12 +213,10 @@ if (!objlist->last) { objlist->last = newit; } - objlist->len++; } else if (pos == objlist->len){ newit->next = NULL; objlist->last->next = newit; objlist->last = newit; - objlist->len++; } else { i = 0; oldit = NULL; @@ -230,8 +226,8 @@ } newit->next = oldit->next; oldit->next = newit; - objlist->len++; } + objlist->len++; return 1; } int comps_objlist_insert_at_x(COMPS_ObjList *objlist, @@ -253,7 +249,7 @@ int comps_objlist_remove_at(COMPS_ObjList *objlist, unsigned int atpos) { int pos; - COMPS_ObjListIt *it, *itprev=NULL, *removed=NULL; + COMPS_ObjListIt *it, *itprev = NULL; if (!objlist) return 0; for (it = objlist->first, pos=0; @@ -261,31 +257,20 @@ it = it->next, pos++) { itprev = it; } - if (atpos == 0 && objlist->first) { - removed = objlist->first; - objlist->first = objlist->first->next; - if (objlist->last == removed) { - objlist->last = NULL; - } - } else if (pos != (int)(atpos)) + if (!it) return 0; - if (itprev) { - removed = it; - if (itprev->next) - itprev->next = itprev->next->next; - else - itprev->next = NULL; - if (removed == objlist->last) { - objlist->last = itprev; - } - } - comps_objlist_it_destroy(removed); + if (itprev) + itprev->next = it->next; + else + objlist->first = it->next; + if (it == objlist->last) + objlist->last = itprev; + comps_objlist_it_destroy(it); objlist->len--; return 1; } int comps_objlist_remove(COMPS_ObjList *objlist, COMPS_Object *obj) { - //int pos; COMPS_ObjListIt *it, *itprev = NULL; if (!objlist) return 0; @@ -293,23 +278,15 @@ it = it->next) { itprev = it; } - if (it == NULL) + if (!it) return 0; - - if (itprev == NULL && it->comps_obj == obj) { - if (objlist->last == objlist->first) - objlist->last = NULL; - objlist->first = objlist->first->next; - comps_object_destroy(it->comps_obj); - free(it); - } else { + if (itprev) itprev->next = it->next; - comps_object_destroy(it->comps_obj); - free(it); - if (it == objlist->last) { - objlist->last = itprev; - } - } + else + objlist->first = it->next; + if (it == objlist->last) + objlist->last = itprev; + comps_objlist_it_destroy(it); objlist->len--; return 1; } @@ -366,6 +343,8 @@ for (it = objlist->first, pos=0; it != NULL && pos != start; it = it->next, pos++); + if (!it) + return ret; for (; it->next != NULL && pos != end; it = it->next, pos++) { comps_objlist_append(ret, it->comps_obj); } @@ -387,6 +366,8 @@ for (it = objlist->first; it != NULL && pos != start; it = it->next, pos++); + if (!it) + return ret; for (; it->next != NULL && pos != end; it = it->next, pos++, stepc++) { if (stepc == step) { step = 0; @@ -471,12 +452,12 @@ const int sep_len = strlen(", "); COMPS_ObjListIt *it = ((COMPS_ObjList*)list)->first; - for (; it != ((COMPS_ObjList*)list)->last; it = it->next, i++) { - tmps = comps_object_tostr(it->comps_obj); - items[i] = tmps; - total_strlen += sep_len + strlen(tmps); - } if (it) { + for (; it != ((COMPS_ObjList*)list)->last; it = it->next, i++) { + tmps = comps_object_tostr(it->comps_obj); + items[i] = tmps; + total_strlen += sep_len + strlen(tmps); + } tmps = comps_object_tostr(it->comps_obj); items[i] = tmps; total_strlen += strlen(tmps); @@ -488,14 +469,14 @@ ret[0]=0; strcat(ret, "["); //total2 += strlen("["); - for (i = 0; i < (int)(((COMPS_ObjList*)list)->len-1); i++) { - strcat(ret, items[i]); - //total2 += strlen(items[i]); - strcat(ret, ", "); - //total2 += strlen(", "); - free(items[i]); - } if (((COMPS_ObjList*)list)->len) { + for (i = 0; i < (int)(((COMPS_ObjList*)list)->len-1); i++) { + strcat(ret, items[i]); + //total2 += strlen(items[i]); + strcat(ret, ", "); + //total2 += strlen(", "); + free(items[i]); + } strcat(ret, items[i]); //total2 += strlen(items[i]); free(items[i]); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/src/comps_objmradix.c new/libcomps-libcomps-0.1.9/libcomps/src/comps_objmradix.c --- old/libcomps-libcomps-0.1.8/libcomps/src/comps_objmradix.c 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/src/comps_objmradix.c 2018-12-12 13:36:35.000000000 +0100 @@ -585,7 +585,10 @@ return; } else if (ended == 1) offset+=x; - else return; + else { + comps_hslist_destroy(&path); + return; + } if ((relation = malloc(sizeof(struct Relation))) == NULL) { comps_hslist_destroy(&path); return; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/src/comps_objradix.c new/libcomps-libcomps-0.1.9/libcomps/src/comps_objradix.c --- old/libcomps-libcomps-0.1.8/libcomps/src/comps_objradix.c 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/src/comps_objradix.c 2018-12-12 13:36:35.000000000 +0100 @@ -540,8 +540,10 @@ break; } } - if (!found) + if (!found) { + comps_hslist_destroy(&path); return; + } rtdata = (COMPS_ObjRTreeData*)it->data; for (x=1; ;x++) { @@ -591,7 +593,10 @@ return; } else if (ended == 1) offset+=x; - else return; + else { + comps_hslist_destroy(&path); + return; + } if ((relation = malloc(sizeof(struct Relation))) == NULL) { comps_hslist_destroy(&path); return; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/src/comps_parse.c new/libcomps-libcomps-0.1.9/libcomps/src/comps_parse.c --- old/libcomps-libcomps-0.1.8/libcomps/src/comps_parse.c 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/src/comps_parse.c 2018-12-12 13:36:35.000000000 +0100 @@ -166,14 +166,12 @@ if (!ret) { err = xmlGetLastError(); printf("%s\n", err->message); + ret = -err->code; } xmlFreeDoc(fptr); xmlFreeDtd(dtd_ptr); xmlFreeValidCtxt(vctxt); - if (!ret) - return -err->code; - else - return ret; + return ret; } void __comps_after_parse(COMPS_Parsed *parsed) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/src/comps_set.c new/libcomps-libcomps-0.1.9/libcomps/src/comps_set.c --- old/libcomps-libcomps-0.1.8/libcomps/src/comps_set.c 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/src/comps_set.c 2018-12-12 13:36:35.000000000 +0100 @@ -108,10 +108,7 @@ return 0; } } - if (set->data_constructor) - comps_hslist_append(set->data, item, 1); - else - comps_hslist_append(set->data, item, 1); + comps_hslist_append(set->data, item, 1); return 1; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/src/comps_utils.c new/libcomps-libcomps-0.1.9/libcomps/src/comps_utils.c --- old/libcomps-libcomps-0.1.8/libcomps/src/comps_utils.c 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/src/comps_utils.c 2018-12-12 13:36:35.000000000 +0100 @@ -38,10 +38,10 @@ inline int __comps_xml_prop(char *key, char *val, xmlTextWriterPtr writer) { - int retc, x; - retc = (x=xmlTextWriterStartElement(writer, BAD_CAST key)<0)?x:retc; - retc = (x=xmlTextWriterWriteString(writer, BAD_CAST val)<0)?x:retc; - retc = (x=xmlTextWriterEndElement(writer)<0)?x:retc; + int retc; + retc = xmlTextWriterStartElement(writer, BAD_CAST key) >= 0 ? 1 : 0; + retc &= xmlTextWriterWriteString(writer, BAD_CAST val) >= 0 ? 1 : 0; + retc &= xmlTextWriterEndElement(writer) >= 0 ? 1 : 0; return retc; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/src/comps_utils.h new/libcomps-libcomps-0.1.9/libcomps/src/comps_utils.h --- old/libcomps-libcomps-0.1.8/libcomps/src/comps_utils.h 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/src/comps_utils.h 2018-12-12 13:36:35.000000000 +0100 @@ -172,7 +172,8 @@ COMPS_ObjList *list); -#define COMPS_XMLRET_CHECK if (ret == -1) {\ +#define COMPS_XMLRET_CHECK(free_code) if (ret == -1) {\ + free_code;\ comps_log_error(log, COMPS_ERR_XMLGEN, 0);\ return -1;\ } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/src/python/docs/doc-sources/comps.rst new/libcomps-libcomps-0.1.9/libcomps/src/python/docs/doc-sources/comps.rst --- old/libcomps-libcomps-0.1.8/libcomps/src/python/docs/doc-sources/comps.rst 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/src/python/docs/doc-sources/comps.rst 2018-12-12 13:36:35.000000000 +0100 @@ -1,12 +1,6 @@ :mod:`libcomps` - Libcomps objects ================================== -.. |FEDORA_IMG| image:: fedora_logo.png - :height: 70 - :width: 200 - :scale: 30 - :alt: Fedora - .. automodule:: libcomps .. autoexception: ParserError @@ -21,7 +15,7 @@ :members: blacklist, langpacks, whiteout - are |FEDORA_IMG| objects only + are Fedora objects only libcomps.GroupList ------------------ Binary files old/libcomps-libcomps-0.1.8/libcomps/src/python/docs/doc-sources/fedora_logo.png and new/libcomps-libcomps-0.1.9/libcomps/src/python/docs/doc-sources/fedora_logo.png differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/src/python/src/pycomps.c new/libcomps-libcomps-0.1.9/libcomps/src/python/src/pycomps.c --- old/libcomps-libcomps-0.1.8/libcomps/src/python/src/pycomps.c 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/src/python/src/pycomps.c 2018-12-12 13:36:35.000000000 +0100 @@ -108,9 +108,6 @@ for (x = 0; keys1[x] != NULL; x++) { val = PyDict_GetItemString(pobj, keys1[x]); if (val) { - if (PyINT_CHECK(val)) { - tmp = PyINT_ASLONG(val); - } tmp = PyLong_AsLong(val); if (tmp == COMPS_PACKAGE_DEFAULT || tmp == COMPS_PACKAGE_OPTIONAL || diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/src/python/src/pycomps_dict.c new/libcomps-libcomps-0.1.9/libcomps/src/python/src/pycomps_dict.c --- old/libcomps-libcomps-0.1.8/libcomps/src/python/src/pycomps_dict.c 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/src/python/src/pycomps_dict.c 2018-12-12 13:36:35.000000000 +0100 @@ -73,7 +73,7 @@ PyObject* PyCOMPSDict_str(PyObject *self) { COMPS_HSList *pairlist; COMPS_HSListItem *it; - PyObject *ret, *tmp, *tmp2, *tmpkey, *tmpval; + PyObject *ret, *tmp = NULL, *tmp2 = NULL, *tmpkey = NULL, *tmpval = NULL; ret = PyUnicode_FromString("{"); pairlist = comps_objdict_pairs(((PyCOMPS_Dict*)self)->dict); char *tmpstr; @@ -83,14 +83,14 @@ tmpkey = __pycomps_lang_decode(((COMPS_ObjRTreePair*)it->data)->key); if (!tmpkey) { PyErr_SetString(PyExc_TypeError, "key convert error"); - return NULL; + goto out; } tmpstr = comps_object_tostr(((COMPS_ObjRTreePair*)it->data)->data); tmpval = __pycomps_lang_decode(tmpstr); free(tmpstr); if (!tmpval) { PyErr_SetString(PyExc_TypeError, "val convert error"); - return NULL; + goto out; } tmp2 = PyUnicode_FromFormat("%U = '%U', ", tmpkey, tmpval); ret = PyUnicode_Concat(ret, tmp2); @@ -102,14 +102,14 @@ tmp = ret; tmpkey = __pycomps_lang_decode(((COMPS_RTreePair*)it->data)->key); if (!tmpkey) { - return NULL; + goto out; } tmpstr = comps_object_tostr(((COMPS_ObjRTreePair*)it->data)->data); tmpval = __pycomps_lang_decode(tmpstr); free(tmpstr); if (!tmpval) { //PyErr_SetString(PyExc_TypeError, "val convert error"); - return NULL; + goto out; } tmp2 = PyUnicode_FromFormat("%U = '%U'", tmpkey, tmpval); ret = PyUnicode_Concat(ret, tmp2); @@ -126,6 +126,14 @@ comps_hslist_destroy(&pairlist); return ret; + + out: + Py_XDECREF(tmp); + Py_XDECREF(tmp2); + Py_XDECREF(tmpkey); + Py_XDECREF(tmpval); + comps_hslist_destroy(&pairlist); + return NULL; } int PyCOMPSDict_print(PyObject *self, FILE *f, int flags) { @@ -155,8 +163,12 @@ PyObject* PyCOMPSDict_cmp(PyObject *self, PyObject *other, int op) { char ret; - if (other == NULL || (Py_TYPE(other) != Py_TYPE(self) && - !PyType_IsSubtype(Py_TYPE(other), Py_TYPE(self)))) { + if (other == NULL) { + PyErr_Format(PyExc_TypeError, "Get NULL as Dict subclass"); + return NULL; + } + if ((Py_TYPE(other) != Py_TYPE(self) && + !PyType_IsSubtype(Py_TYPE(other), Py_TYPE(self)))) { PyErr_Format(PyExc_TypeError, "Not Dict subclass, %s", Py_TYPE(other)->tp_name); return NULL; @@ -190,8 +202,12 @@ return ret; } PyObject* PyCOMPSDict_update(PyObject *self, PyObject *other) { - if (other == NULL || (Py_TYPE(other) != Py_TYPE(self) && - !PyType_IsSubtype(Py_TYPE(other), Py_TYPE(self)))) { + if (other == NULL) { + PyErr_Format(PyExc_TypeError, "Get NULL as Dict subclass"); + return NULL; + } + if ((Py_TYPE(other) != Py_TYPE(self) && + !PyType_IsSubtype(Py_TYPE(other), Py_TYPE(self)))) { PyErr_Format(PyExc_TypeError, "Not %s type or subclass, %s", Py_TYPE(self)->tp_name, Py_TYPE(other)->tp_name); return NULL; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/src/python/src/pycomps_mdict.c new/libcomps-libcomps-0.1.9/libcomps/src/python/src/pycomps_mdict.c --- old/libcomps-libcomps-0.1.8/libcomps/src/python/src/pycomps_mdict.c 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/src/python/src/pycomps_mdict.c 2018-12-12 13:36:35.000000000 +0100 @@ -69,7 +69,7 @@ PyObject* PyCOMPSMDict_str(PyObject *self) { COMPS_HSList *pairlist; COMPS_HSListItem *it; - PyObject *ret, *tmp, *tmp2, *tmpkey, *tmpval; + PyObject *ret, *tmp = NULL, *tmp2 = NULL, *tmpkey = NULL, *tmpval = NULL; ret = PyUnicode_FromString("{"); pairlist = comps_objmdict_pairs(((PyCOMPS_MDict*)self)->dict); char *tmpstr; @@ -79,7 +79,7 @@ tmpkey = __pycomps_lang_decode(((COMPS_ObjMRTreePair*)it->data)->key); if (!tmpkey) { PyErr_SetString(PyExc_TypeError, "key convert error"); - return NULL; + goto out; } tmpstr = comps_object_tostr((COMPS_Object*) ((COMPS_ObjMRTreePair*)it->data)->data); @@ -87,7 +87,7 @@ free(tmpstr); if (!tmpval) { PyErr_SetString(PyExc_TypeError, "val convert error"); - return NULL; + goto out; } tmp2 = PyUnicode_FromFormat("%U = '%U', ", tmpkey, tmpval); ret = PyUnicode_Concat(ret, tmp2); @@ -100,7 +100,7 @@ tmpkey = __pycomps_lang_decode(((COMPS_ObjMRTreePair*)it->data)->key); if (!tmpkey) { //PyErr_SetString(PyExc_TypeError, "key convert error"); - return NULL; + goto out; } tmpstr = comps_object_tostr((COMPS_Object*) ((COMPS_ObjMRTreePair*)it->data)->data); @@ -110,7 +110,7 @@ free(tmpstr); if (!tmpval) { //PyErr_SetString(PyExc_TypeError, "val convert error"); - return NULL; + goto out; } tmp2 = PyUnicode_FromFormat("%U = '%U'", tmpkey, tmpval); ret = PyUnicode_Concat(ret, tmp2); @@ -127,6 +127,15 @@ comps_hslist_destroy(&pairlist); return ret; + + out: + Py_XDECREF(tmp); + Py_XDECREF(tmp2); + Py_XDECREF(tmpkey); + Py_XDECREF(tmpval); + comps_hslist_destroy(&pairlist); + return NULL; + } int PyCOMPSMDict_print(PyObject *self, FILE *f, int flags) { @@ -159,8 +168,12 @@ PyObject* PyCOMPSMDict_cmp(PyObject *self, PyObject *other, int op) { char ret; - if (other == NULL || (Py_TYPE(other) != Py_TYPE(self) && - !PyType_IsSubtype(Py_TYPE(other), Py_TYPE(self)))) { + if (other == NULL) { + PyErr_Format(PyExc_TypeError, "Get NULL as Dict subclass"); + return NULL; + } + if ((Py_TYPE(other) != Py_TYPE(self) && + !PyType_IsSubtype(Py_TYPE(other), Py_TYPE(self)))) { PyErr_Format(PyExc_TypeError, "Not Dict subclass, %s", Py_TYPE(other)->tp_name); return NULL; @@ -194,8 +207,12 @@ return ret; } PyObject* PyCOMPSMDict_update(PyObject *self, PyObject *other) { - if (other == NULL || (Py_TYPE(other) != Py_TYPE(self) && - !PyType_IsSubtype(Py_TYPE(other), Py_TYPE(self)))) { + if (other == NULL) { + PyErr_Format(PyExc_TypeError, "Get NULL as Dict subclass"); + return NULL; + } + if ((Py_TYPE(other) != Py_TYPE(self) && + !PyType_IsSubtype(Py_TYPE(other), Py_TYPE(self)))) { PyErr_Format(PyExc_TypeError, "Not %s type or subclass, %s", Py_TYPE(self)->tp_name, Py_TYPE(other)->tp_name); return NULL; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/src/python/src/pycomps_sequence.c new/libcomps-libcomps-0.1.9/libcomps/src/python/src/pycomps_sequence.c --- old/libcomps-libcomps-0.1.8/libcomps/src/python/src/pycomps_sequence.c 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/src/python/src/pycomps_sequence.c 2018-12-12 13:36:35.000000000 +0100 @@ -257,13 +257,17 @@ clen = 0; it = ((PyCOMPS_Sequence*)self)->list->first; + if (!it) + return (PyObject*)result; for (i=0 ; i<istart; it=it->next, i++); while (clen != ilen) { comps_objlist_append(result->list, it->comps_obj); clen+=1; - for (i=0 ; i<istep && it != NULL; it=it->next, i++); - if (!it) it = ((PyCOMPS_Sequence*)self)->list->first; - for (; i<istep; it=it->next, i++); + i = 0; + do { + for (; i<istep && it != NULL; it=it->next, i++); + if (!it) it = ((PyCOMPS_Sequence*)self)->list->first; + } while (i < istep); } return (PyObject*)result; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/tests/check_objrtree.c new/libcomps-libcomps-0.1.9/libcomps/tests/check_objrtree.c --- old/libcomps-libcomps-0.1.8/libcomps/tests/check_objrtree.c 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/tests/check_objrtree.c 2018-12-12 13:36:35.000000000 +0100 @@ -54,10 +54,14 @@ if (!rt) return NULL; f = fopen(filename, "r"); - if (!f) return NULL; + if (!f) { + COMPS_OBJECT_DESTROY(rt); + return NULL; + } while (!feof(f)) { memset(buffer, 0, 100); if (!fgets(buffer, 100, f)) + fclose(f); return rt; buffer[strlen(buffer)-1] =0; //printf("buffer:%s\n", buffer); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/tests/check_parse.c new/libcomps-libcomps-0.1.9/libcomps/tests/check_parse.c --- old/libcomps-libcomps-0.1.8/libcomps/tests/check_parse.c 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/tests/check_parse.c 2018-12-12 13:36:35.000000000 +0100 @@ -64,11 +64,6 @@ const char* cats_names[] = {"category 1", "category 2"}; const int cats_gids[] = {1, 2}; - const char* envs_ids[] = {"env 1"}; - const char* envs_names[] = {"environment 1"}; - const char* env_gids[][3] = {{"a", "b", "c"}}; - const char* env_opids[][2] = {{" option 1 ", " option 2 "}}; - int ret; COMPS_Object *tmpobj, *tmpobj2; char *tmpstr; @@ -305,13 +300,11 @@ { FILE *fp; //char *err_log, - char *tmp_ch; COMPS_Parsed *parsed; COMPS_ObjListIt *it; int i; COMPS_ObjList *tmplist; COMPS_LogEntry* known_errors[3]; - char *str; COMPS_Object *tmpobj; fprintf(stderr, "## Running test_parse3\n\n"); @@ -525,7 +518,6 @@ COMPS_DocGroup *g; COMPS_DocCategory *c; COMPS_DocEnv *e; - COMPS_DocGroupPackage *p; COMPS_Str *str; int x; COMPS_ObjListIt *it; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/tests/check_rtree.c new/libcomps-libcomps-0.1.9/libcomps/tests/check_rtree.c --- old/libcomps-libcomps-0.1.8/libcomps/tests/check_rtree.c 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/tests/check_rtree.c 2018-12-12 13:36:35.000000000 +0100 @@ -96,11 +96,16 @@ if (!rt) return NULL; f = fopen(filename, "r"); - if (!f) return NULL; + if (!f) { + comps_rtree_destroy(rt); + return NULL; + } while (!feof(f)) { memset(buffer, 0, 100); - if (!fgets(buffer, 100, f)) + if (!fgets(buffer, 100, f)) { + fclose(f); return rt; + } buffer[strlen(buffer)-1] =0; //printf("buffer:%s\n", buffer); pch = strrchr(buffer, '-'); @@ -114,6 +119,7 @@ printf("%s\n", ((COMPS_RTreeData*)it->data)->key); }*/ } + fclose(f); return rt; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/tests/check_utils.c new/libcomps-libcomps-0.1.9/libcomps/tests/check_utils.c --- old/libcomps-libcomps-0.1.8/libcomps/tests/check_utils.c 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/tests/check_utils.c 2018-12-12 13:36:35.000000000 +0100 @@ -108,9 +108,9 @@ disp_ord = (prop)?((COMPS_Num*)prop)->val:0; COMPS_OBJECT_DESTROY(prop); - printf("id: %s\n", id); - printf("name: %s\n", name); - printf("desc: %s\n", desc); + printf("id: %s\n", id ? id : "(null)"); + printf("name: %s\n", name ? name : "(null)"); + printf("desc: %s\n", desc ? desc : "(null)"); printf("display_order: %d\n", disp_ord); free(id); free(name); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/libcomps/version.cmake new/libcomps-libcomps-0.1.9/libcomps/version.cmake --- old/libcomps-libcomps-0.1.8/libcomps/version.cmake 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/libcomps/version.cmake 2018-12-12 13:36:35.000000000 +0100 @@ -1,5 +1,5 @@ set (libcomps_VERSION_MAJOR 0) set (libcomps_VERSION_MINOR 1) -set (libcomps_VERSION_PATCH 6) -set (libcomps_RELEASE 9) +set (libcomps_VERSION_PATCH 9) +set (libcomps_RELEASE 1) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/ver-bump.py new/libcomps-libcomps-0.1.9/ver-bump.py --- old/libcomps-libcomps-0.1.8/ver-bump.py 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/ver-bump.py 2018-12-12 13:36:35.000000000 +0100 @@ -10,12 +10,19 @@ try: if sys.argv[1] == "major": version["libcomps_VERSION_MAJOR"] += 1 + version["libcomps_VERSION_MINOR"] = 1 + version["libcomps_VERSION_PATCH"] = 1 + version["libcomps_RELEASE"] = 1 elif sys.argv[1] == "minor": version["libcomps_VERSION_MINOR"] += 1 + version["libcomps_VERSION_PATCH"] = 1 + version["libcomps_RELEASE"] = 1 elif sys.argv[1] == "patch": version["libcomps_VERSION_PATCH"] += 1 + version["libcomps_RELEASE"] = 1 except IndexError: version["libcomps_VERSION_PATCH"] += 1 + version["libcomps_RELEASE"] = 1 f = open("version.json", "w") json.dump(version, f, indent=4) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libcomps-libcomps-0.1.8/version.json new/libcomps-libcomps-0.1.9/version.json --- old/libcomps-libcomps-0.1.8/version.json 2016-09-06 15:17:11.000000000 +0200 +++ new/libcomps-libcomps-0.1.9/version.json 2018-12-12 13:36:35.000000000 +0100 @@ -1,6 +1,6 @@ { "libcomps_VERSION_MAJOR": 0, - "libcomps_RELEASE": 9, + "libcomps_RELEASE": 1, "libcomps_VERSION_MINOR": 1, - "libcomps_VERSION_PATCH": 6 + "libcomps_VERSION_PATCH": 9 } \ No newline at end of file
