Skip to content

Commit

Permalink
NULL-check before freeing set in _parse_modulemd_filters
Browse files Browse the repository at this point in the history
Fixes: #26

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
  • Loading branch information
sgallagher committed Mar 15, 2018
1 parent 9424d18 commit e4bb64f
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modulemd/modulemd-yaml-parser-modulemd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,7 @@ _parse_modulemd_filters (ModulemdModule *module,

error:
yaml_event_delete (&event);
g_object_unref (set);
g_clear_pointer (&set, g_object_unref);

g_debug ("TRACE: exiting _parse_modulemd_filters");
return result;
Expand Down
28 changes: 28 additions & 0 deletions modulemd/test-modulemd-regressions.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,27 @@ modulemd_regressions_issue25 (RegressionFixture *fixture,
"%my_macro 1");
}


static void
modulemd_regressions_issue26 (RegressionFixture *fixture,
gconstpointer user_data)
{
gchar *yaml_path;
ModulemdModule *module = NULL;

/* This would segfault because we weren't checking for NULL
* prior to attempting to free the simpleset in
* _parse_modulemd_filters
*/
yaml_path = g_strdup_printf ("%s/test_data/issue26.yaml",
g_getenv ("MESON_SOURCE_ROOT"));
module = modulemd_module_new_from_file (yaml_path);
g_assert_nonnull (module);

g_object_unref (module);
}


int
main (int argc, char *argv[])
{
Expand Down Expand Up @@ -192,5 +213,12 @@ main (int argc, char *argv[])
modulemd_regressions_issue25,
NULL);

g_test_add ("/modulemd/regressions/issue26",
RegressionFixture,
NULL,
NULL,
modulemd_regressions_issue26,
NULL);

return g_test_run ();
}
61 changes: 61 additions & 0 deletions test_data/issue26.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
data:
api:
rpms: [tangerine, perl-Tangerine]
components:
rpms:
perl-List-Compare: {cache: 'http://pkgs.fedoraproject.org/repo/pkgs/perl-List-Compare',
rationale: A dependency of tangerine., ref: 76f9d8c8e87eed0aab91034b01d3d5ff6bd5b4cb,
repository: 'git://pkgs.fedoraproject.org/rpms/perl-List-Compare'}
perl-Tangerine: {cache: 'http://pkgs.fedoraproject.org/repo/pkgs/perl-Tangerine',
rationale: Provides API for this module and is a dependency of tangerine.,
ref: 4ceea43add2366d8b8c5a622a2fb563b625b9abf, repository: 'git://pkgs.fedoraproject.org/rpms/perl-Tangerine'}
tangerine: {buildorder: 10, cache: 'http://pkgs.fedoraproject.org/repo/pkgs/tangerine',
rationale: Provides API for this module., ref: fbed359411a1baa08d4a88e0d12d426fbf8f602c,
repository: 'git://pkgs.fedoraproject.org/rpms/tangerine'}
dependencies:
buildrequires:
zebra: stripes
base-runtime: master
fluffy: slippers
requires:
fidget: spinner
base-runtime: master
silly: puddy
glass: water
description: This module demonstrates how to write simple modulemd files And can
be used for testing the build and release pipeline.
filter: {}
license:
module: [MIT]
name: testmodule
profiles:
default:
rpms: [tangerine]
references: {community: 'https://fedoraproject.org/wiki/Modularity', documentation: 'https://fedoraproject.org/wiki/Fedora_Packaging_Guidelines_for_Modules',
tracker: 'https://taiga.fedorainfracloud.org/project/modularity'}
stream: master
summary: A test module in all its beautiful beauty
version: 20170109091357
xmd:
mbs:
buildrequires:
zebra:
ref: 08f8671f5925ecbd7c55d83e8368dd0be81ef8ed
base-runtime:
ref: ae993ba84f4bce554471382ccba917ef16265f11
fluffy:
ref: ea83325b231f64c575ea104bb698e9d43b80469a
requires:
fidget:
ref: 5aa32bd61aadaec8295ef90f79daaf190e387509
base-runtime:
ref: ae993ba84f4bce554471382ccba917ef16265f11
silly:
ref: 0e2a1f9246118180d61aad731923ebd85154bc6e
glass:
ref: ea8753e832974dd5b0d95cd6bb7d26727d2ba742
commit: 7fea453bc362cc8e5aa41e129e689baea853653d
scmurl: git://pkgs.stg.fedoraproject.org/modules/testmodule.git?#7fea453
document: modulemd
version: 1

0 comments on commit e4bb64f

Please sign in to comment.