From owner-svn-src-all@freebsd.org Fri May 25 15:16:14 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A1089EEA6B7; Fri, 25 May 2018 15:16:14 +0000 (UTC) (envelope-from araujobsdport@gmail.com) Received: from mail-wm0-x233.google.com (mail-wm0-x233.google.com [IPv6:2a00:1450:400c:c09::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id ED31485065; Fri, 25 May 2018 15:16:13 +0000 (UTC) (envelope-from araujobsdport@gmail.com) Received: by mail-wm0-x233.google.com with SMTP id x2-v6so8186038wmh.5; Fri, 25 May 2018 08:16:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=EgXIZrfXBaCFqcL2+Xez6xkyyfhMr6yjTJPSVaFe8/w=; b=G4HTyHPUQYUC+KfNd9VJM/Vmi0mGHWLHt5zEv6D6eHlVNOP+6z2ROQhnYkA4SSoijA HxpyPe/GRIKCikd9G0c3g5ImctBebHg8GyC4IGKK8IcszUw+0BM7IMj6uGwDuidcW+Kz He6v8sVF6akBotQ+S5/CMqji5Lm+ctoYHl/5CLNcHcuWiqBwUezvqaYuj5EBkUNM8csD MwdmeqE1l8fGYm5rerrw0jc3m8yOy5Zox6hwz/jtXpwi4rjKDRxkHtDuVg7jm0Y50giU Xf9CS4rNy3fbVXx9j7HNHv3+2lwU3T5m+CcKjL/Ub+0at/Ks8hNkO3tv6yCXBqUXssas XiFA== 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:reply-to :from:date:message-id:subject:to:cc; bh=EgXIZrfXBaCFqcL2+Xez6xkyyfhMr6yjTJPSVaFe8/w=; b=CAo/ByrwnJ1jOjrU2EPcDVEbiEGs950wDACEYWcye9MIqugzIRovx8KIUSr1aJH8bL ua5Nh33SRAG64seZuYIn5/jve3gSmjcG9KKh+dc8HmDTgGQ9MoOM2tKZ4muYjYlcPa4m pWUZT1mI29qzQGLYXQUhDaaXb03LVqVSst5PsVROzw0cTi+XFVlOe6bY5y10VNnJOs1N 3+jcBp6drlHOAYVUijzRWlk51eiBGqzCPUEXQLaJvJsOWbTbQZKQjFdWjEIxGI+IGqJ3 4BtIlHvPI/55SYArhwFoUmKQW5a7lMShorVLS3QHKG/nRTpis9cXr8rIwEtKVSFTt034 YLLg== X-Gm-Message-State: ALKqPwcRWrWKzcsxj0vfpEO+cbfPpIphlTLq7KGG6O04GWG6yGUx3Yxk okHBWoMSveofAm82Kfc5Q2Ff39xGUZhx5PvN45g= X-Google-Smtp-Source: AB8JxZoJvr9pFbbVD091RnxS0rPoOCpiGzNF1n70MA5zjtiLhF0lH6I0qzhfe0PV1L3n7ty/QcfU5x5NnoIAT2zpOU8= X-Received: by 2002:a2e:5019:: with SMTP id e25-v6mr2031027ljb.122.1527261372633; Fri, 25 May 2018 08:16:12 -0700 (PDT) MIME-Version: 1.0 References: <201805250207.w4P275Pf060725@repo.freebsd.org> <20180525151134.GB99063@spindle.one-eyed-alien.net> In-Reply-To: <20180525151134.GB99063@spindle.one-eyed-alien.net> Reply-To: araujo@freebsd.org From: Marcelo Araujo Date: Fri, 25 May 2018 23:16:00 +0800 Message-ID: Subject: Re: svn commit: r334199 - head/usr.sbin/bhyve To: Brooks Davis Cc: Marcelo Araujo , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.26 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 May 2018 15:16:14 -0000 On Fri, May 25, 2018, 11:11 PM Brooks Davis wrote: > On Fri, May 25, 2018 at 02:07:05AM +0000, Marcelo Araujo wrote: > > Author: araujo > > Date: Fri May 25 02:07:05 2018 > > New Revision: 334199 > > URL: https://svnweb.freebsd.org/changeset/base/334199 > > > > Log: > > Fix a memory leak on topology_parse(). > > > > strdup(3) allocates memory for a copy of the string, does the copy and > > returns a pointer to it. If there is no sufficient memory NULL is > returned > > and the global errno is set to ENOMEM. > > We do a sanity check to see if it was possible to allocate enough > memory. > > > > Also as we allocate memory, we need to free this memory used. Or it > will > > going out of scope leaks the storage it points to. > > > > Reviewed by: rgrimes > > MFC after: 3 weeks. > > X-MFC: r332298 > > Sponsored by: iXsystems Inc. > > Differential Revision: https://reviews.freebsd.org/D15550 > > > > Modified: > > head/usr.sbin/bhyve/bhyverun.c > > > > Modified: head/usr.sbin/bhyve/bhyverun.c > > > ============================================================================== > > --- head/usr.sbin/bhyve/bhyverun.c Fri May 25 01:38:59 2018 > (r334198) > > +++ head/usr.sbin/bhyve/bhyverun.c Fri May 25 02:07:05 2018 > (r334199) > > @@ -193,6 +193,7 @@ topology_parse(const char *opt) > > c = 1, n = 1, s = 1, t = 1; > > ns = false, scts = false; > > str = strdup(opt); > > + assert(str != NULL); > > Using assert seems like an odd choice when you've already added a > failure path and the strsep will crash immediately if assert is elided. > Why assert is an odd choice? Have a better suggestion? > > -- Brooks >