From owner-svn-src-head@FreeBSD.ORG Wed Jun 11 17:19:58 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3ADFBFA7; Wed, 11 Jun 2014 17:19:58 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 283FC2E8E; Wed, 11 Jun 2014 17:19:58 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s5BHJwWl090629; Wed, 11 Jun 2014 17:19:58 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s5BHJw3O090628; Wed, 11 Jun 2014 17:19:58 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201406111719.s5BHJw3O090628@svn.freebsd.org> From: Ed Maste Date: Wed, 11 Jun 2014 17:19:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r267366 - head/usr.bin/vtfontcvt X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jun 2014 17:19:58 -0000 Author: emaste Date: Wed Jun 11 17:19:57 2014 New Revision: 267366 URL: http://svnweb.freebsd.org/changeset/base/267366 Log: Avoid leaking file pointer on error CID: 1222506, 1222505 Modified: head/usr.bin/vtfontcvt/vtfontcvt.c Modified: head/usr.bin/vtfontcvt/vtfontcvt.c ============================================================================== --- head/usr.bin/vtfontcvt/vtfontcvt.c Wed Jun 11 17:03:14 2014 (r267365) +++ head/usr.bin/vtfontcvt/vtfontcvt.c Wed Jun 11 17:19:57 2014 (r267366) @@ -331,6 +331,7 @@ parse_file(const char *filename, unsigne { FILE *fp; size_t len; + int rv; fp = fopen(filename, "r"); if (fp == NULL) { @@ -339,8 +340,11 @@ parse_file(const char *filename, unsigne } len = strlen(filename); if (len > 4 && strcasecmp(filename + len - 4, ".hex") == 0) - return parse_hex(fp, map_idx); - return parse_bdf(fp, map_idx); + rv = parse_hex(fp, map_idx); + else + rv = parse_bdf(fp, map_idx); + fclose(fp); + return (rv); } static void @@ -447,6 +451,7 @@ write_fnt(const char *filename) fh.map_count[3] = htobe32(map_folded_count[3]); if (fwrite(&fh, sizeof fh, 1, fp) != 1) { perror(filename); + fclose(fp); return (1); } @@ -456,9 +461,11 @@ write_fnt(const char *filename) write_mappings(fp, VFNT_MAP_BOLD) != 0 || write_mappings(fp, 3) != 0) { perror(filename); + fclose(fp); return (1); } + fclose(fp); return (0); }