From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 738B2C47094 for ; Thu, 10 Jun 2021 14:43:56 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1F05C613F8 for ; Thu, 10 Jun 2021 14:43:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F05C613F8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrLuV-0002TA-Af for qemu-devel@archiver.kernel.org; Thu, 10 Jun 2021 10:43:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrLsL-0007FE-Lg for qemu-devel@nongnu.org; Thu, 10 Jun 2021 10:41:41 -0400 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]:40810) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lrLsJ-0006iG-UO for qemu-devel@nongnu.org; Thu, 10 Jun 2021 10:41:41 -0400 Received: by mail-ej1-x62b.google.com with SMTP id my49so27879583ejc.7 for ; Thu, 10 Jun 2021 07:41:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eD03mD8ruiBy5YVjRLjOSutdt9TGYJ9tV/7EMA9zoO4=; b=O5lUDMmaYdpvebpl4Q+k4vYv210rci8Y5/uh4GbTaClvM/+omtIY/Yk1HOTxsaGKkZ FgoB5vlWJRJ2Z4HQVZkgfTqfhIdH//CGOqsCvI0svrAvizMUmp0NSZMCh+ruxtZ81MuY 8PSjtyEDNhusIAqsl57P0wgsfXSRtgfWKmuVPjZ2q3ydCmUh4mK++wolaKe0at8ir88A nQ0OOx8U5pvy89bne73U6Q/A/cG0vquZGhhQBnz2T8p8O7rV5Mnhga3E7JDcYYNwkCX8 L9/ugdVvXzK5o+WxktfYMtRERtEdH2Fbcwcc1Uc1F9R92+h/4wHRPYEEfALi0B321G9E wYrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eD03mD8ruiBy5YVjRLjOSutdt9TGYJ9tV/7EMA9zoO4=; b=eWudKzJ4H4FMHpfGmhrjjJCysmf85wLwfiMV9AgDVo4Kgry9/W2OCM5ujESXdImNDB PTTfZyr/D+OLZK56+8DGl1DdQNW/GK3BOxYrd2Yf91EDWgTGhbF5eD5KaK/HVJQsHoax tErGK1fG6pS9AqL++Kcz2S0z4vFkFymdiSyMpLS+Asnd5Wai55km5eD3T1CI8/rxWZw9 JE9U2/yrsc2gWxg8jWkA5foezhSC4f++44Qrv3b2Vh12SF00JoQ4yIvnBTSeN4qGxdFU Lmg/F0nsRW6jjFNWQZV2cVV76nDM3OAD6mFXy3gOt276Ng70gV/GPmoJxiIuNAlSh47N XTlg== X-Gm-Message-State: AOAM530LfAt8SD9yibzVT0uLCkefd0I4w+s4ChAdD0GPmPrxU8kbQcYy xrDSyuBTQcRCXcEGT5P5ed8PS7RmZXL6ienSiYI= X-Google-Smtp-Source: ABdhPJyf1kKa8ftcA3svMug2L4psnpvk3foZi4CR/MLTU7gt5hYRXJq0C3xgPdzuJ74m6ACnqlEiu/DTL35HrnnOUOA= X-Received: by 2002:a17:906:4483:: with SMTP id y3mr4963090ejo.92.1623336098496; Thu, 10 Jun 2021 07:41:38 -0700 (PDT) MIME-Version: 1.0 References: <20210610143800.3293854-1-konstantin@daynix.com> In-Reply-To: <20210610143800.3293854-1-konstantin@daynix.com> From: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= Date: Thu, 10 Jun 2021 18:41:26 +0400 Message-ID: Subject: Re: [PATCH] qga-win: Free GMatchInfo properly To: Kostiantyn Kostiuk Content-Type: multipart/alternative; boundary="0000000000008083ce05c46a63a2" Received-SPF: pass client-ip=2a00:1450:4864:20::62b; envelope-from=marcandre.lureau@gmail.com; helo=mail-ej1-x62b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: QEMU , Michael Roth Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --0000000000008083ce05c46a63a2 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi On Thu, Jun 10, 2021 at 6:38 PM Kostiantyn Kostiuk wrote: > The g_regex_match function creates match_info even if it > returns FALSE. So we should always call g_match_info_free. > > Signed-off-by: Kostiantyn Kostiuk > --- > qga/commands-win32.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/qga/commands-win32.c b/qga/commands-win32.c > index 300b87c859..e8bc3df306 100644 > --- a/qga/commands-win32.c > +++ b/qga/commands-win32.c > @@ -2497,6 +2497,7 @@ GuestDeviceInfoList *qmp_guest_get_devices(Error > **errp) > GMatchInfo *match_info; > What about using g_autoptr instead? GuestDeviceIdPCI *id; > if (!g_regex_match(device_pci_re, hw_ids[j], 0, &match_info)= ) > { > + g_match_info_free(match_info); > continue; > } > skip =3D false; > -- > 2.25.1 > > > --=20 Marc-Andr=C3=A9 Lureau --0000000000008083ce05c46a63a2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi

On Thu, Jun 10, 2021 at 6:38 PM Kos= tiantyn Kostiuk <konstantin@day= nix.com> wrote:
The g_regex_match function creates match_info even if it
returns FALSE. So we should always call g_match_info_free.

Signed-off-by: Kostiantyn Kostiuk <konstantin@daynix.com>
---
=C2=A0qga/commands-win32.c | 1 +
=C2=A01 file changed, 1 insertion(+)

diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 300b87c859..e8bc3df306 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -2497,6 +2497,7 @@ GuestDeviceInfoList *qmp_guest_get_devices(Error **er= rp)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0GMatchInfo *match_info;
=

What about using g_autoptr instead?
<= div>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0GuestDeviceIdPCI *id;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!g_regex_match(device_p= ci_re, hw_ids[j], 0, &match_info)) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 g_match_info_free(= match_info);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0continue;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0skip =3D false;
--
2.25.1




--
Marc-Andr=C3=A9 Lureau
--0000000000008083ce05c46a63a2--