From e3fed4c3ebcfe35b8363efc0504a94e93edbbec7 Mon Sep 17 00:00:00 2001 From: pancake Date: Sun, 6 Nov 2022 06:22:50 +0100 Subject: [PATCH] v.pkgconfig: fix infinite recursion bug when parsing dependencies (#16342) --- vlib/v/pkgconfig/pkgconfig.v | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vlib/v/pkgconfig/pkgconfig.v b/vlib/v/pkgconfig/pkgconfig.v index ad002dcadc..2006929bd7 100644 --- a/vlib/v/pkgconfig/pkgconfig.v +++ b/vlib/v/pkgconfig/pkgconfig.v @@ -46,6 +46,7 @@ pub mut: requires []string requires_private []string conflicts []string + loaded []string } fn (mut pc PkgConfig) parse_list_no_comma(s string) []string { @@ -199,8 +200,13 @@ fn (mut pc PkgConfig) load_requires() ? { } fn (mut pc PkgConfig) load_require(dep string) ? { + if dep in pc.loaded { + return + } + pc.loaded << dep mut pcdep := PkgConfig{ paths: pc.paths + loaded: pc.loaded } depfile := pcdep.resolve(dep) or { if pc.options.debug { @@ -211,7 +217,9 @@ fn (mut pc PkgConfig) load_require(dep string) ? { if !pcdep.parse(depfile) { return error('required file "$depfile" could not be parsed') } - pcdep.load_requires()? + if !pc.options.norecurse { + pcdep.load_requires()? + } pc.extend(pcdep)? }