Received: from eggs.gnu.org ([2001:4830:134:3::10]:49659) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wnm1c-0004iN-BH for qemu-devel@nongnu.org; Fri, 23 May 2014 05:44:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wnm1W-0001Gw-93 for qemu-devel@nongnu.org; Fri, 23 May 2014 05:44:28 -0400 Received: from oxygen.pond.sub.org ([144.76.244.19]:41727) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wnm1W-0001F5-2N for qemu-devel@nongnu.org; Fri, 23 May 2014 05:44:22 -0400 From: Markus Armbruster References: <1400770642-18196-1-git-send-email-armbru@redhat.com> <1400770642-18196-6-git-send-email-armbru@redhat.com> <537F1429.90202@msgid.tls.msk.ru> Date: Fri, 23 May 2014 11:44:07 +0200 In-Reply-To: <537F1429.90202@msgid.tls.msk.ru> (Michael Tokarev's message of "Fri, 23 May 2014 13:26:01 +0400") Message-ID: <87y4xssuc8.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 5/7] libcacard: Convert two leftover realloc() to GLib List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Tokarev Cc: alevy@redhat.com, qemu-devel@nongnu.org Michael Tokarev writes: > 22.05.2014 18:57, Markus Armbruster wrote: > >> diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c >> index 692534c..f98541f 100644 >> --- a/libcacard/vcard_emul_nss.c >> +++ b/libcacard/vcard_emul_nss.c >> @@ -1178,11 +1178,7 @@ vcard_emul_options(const char *args) >> >> if (opts->vreader_count >= reader_count) { >> reader_count += READER_STEP; >> - vreaderOpt = realloc(opts->vreader, >> - reader_count * sizeof(*vreaderOpt)); >> - if (vreaderOpt == NULL) { >> - return opts; /* we're done */ >> - } >> + vreaderOpt = g_new(VirtualReaderOptions, reader_count); >> } >> opts->vreader = vreaderOpt; > > This does not look like equivalent code. It is equivalent > to malloc(), not realloc(). So we'll leak old opts->vreader > on every expansion of the array, and will lose old elements > in it too. Typo, meant g_renew(), will respin. Thanks!