From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RtjCx-00027e-2z for garchives@archives.gentoo.org; Sat, 04 Feb 2012 17:15:27 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 67B4DE0671; Sat, 4 Feb 2012 17:15:18 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 1C70DE0671 for ; Sat, 4 Feb 2012 17:15:18 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 5CABA1B4003 for ; Sat, 4 Feb 2012 17:15:17 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id C090780042 for ; Sat, 4 Feb 2012 17:15:16 +0000 (UTC) From: "José María Alonso" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "José María Alonso" Message-ID: <7193aa1fa1a5dbf2f0c714ff0e88f04bea5e962f.nimiux@gentoo> Subject: [gentoo-commits] proj/conf-update:master commit in: / X-VCS-Repository: proj/conf-update X-VCS-Files: helpers.c index.c X-VCS-Directories: / X-VCS-Committer: nimiux X-VCS-Committer-Name: José María Alonso X-VCS-Revision: 7193aa1fa1a5dbf2f0c714ff0e88f04bea5e962f Date: Sat, 4 Feb 2012 17:15:16 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 9004075f-292f-42b1-ada8-89afd6d3b681 X-Archives-Hash: 55176ab530f8faa559a405b566af1120 commit: 7193aa1fa1a5dbf2f0c714ff0e88f04bea5e962f Author: Jos=C3=A9 Mar=C3=ADa Alonso AuthorDate: Sat Feb 4 17:12:18 2012 +0000 Commit: Jos=C3=A9 Mar=C3=ADa Alonso gentoo org> CommitDate: Sat Feb 4 17:12:18 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/conf-update.g= it;a=3Dcommit;h=3D7193aa1f Fixed some memory leaks. Thanks to Vincent Huisman. --- helpers.c | 23 +++++++++++++++++------ index.c | 8 +++++--- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/helpers.c b/helpers.c index a56e65d..976cd3b 100644 --- a/helpers.c +++ b/helpers.c @@ -34,6 +34,9 @@ char **get_listing(char *cmd, char *delim) { } free(buf_backup); // make sure the last one is always LAST_ENTRY + if(i =3D=3D count) { + free(listing[count-1]); + } listing[count-1] =3D LAST_ENTRY; pclose(pipe); return listing; @@ -135,7 +138,6 @@ struct node *fold_updates(char **list) { newnode->dir =3D FALSE; newnode->link =3D &list[i]; } else { - newnode->name =3D strdup(curtok); newnode->dir =3D TRUE; newnode->link =3D NULL; } @@ -194,6 +196,7 @@ void sanity_checks() { strndup(config.merge_tool, strchrnul(config.merge_tool, ' ') - config.= merge_tool), strndup(config.edit_tool, strchrnul(config.edit_tool, ' ') - config.ed= it_tool) }; + gchar *program_in_path; =09 if (getuid() !=3D 0) { fprintf(stderr, "!!! Oops, you're not root!\n"); @@ -203,13 +206,19 @@ void sanity_checks() { for (i=3D0;ict_children;i++) { free_folded(root->children[i]); } - if (root->dir) { + // if (root->dir) { // it seems name is assigned unconditionally since = $sometime free(root->name); - } + // } free(root->children); free(root); } @@ -401,7 +410,9 @@ char **get_files_list(char *searchpath, char **index,= int *max) { char *myfile; bool ignore; =09 - lstat(searchpath, &mystat); + if(-1 =3D=3D lstat(searchpath, &mystat)) { + return index; + } if (S_ISDIR(mystat.st_mode)) { dirfd =3D opendir(searchpath); if (dirfd) { @@ -434,7 +445,7 @@ char **get_files_list(char *searchpath, char **index,= int *max) { } else { // we don't want duplicates either ignore =3D FALSE; - for (j=3D0;j<(*max);j++) { + for (j=3D0;j<(*max) && index[j] !=3D LAST_ENTRY;j++) { lstat(index[j], &tmpstat); if (tmpstat.st_dev =3D=3D mystat.st_dev && \ tmpstat.st_ino =3D=3D mystat.st_ino) { diff --git a/index.c b/index.c index 96bb227..5048da4 100644 --- a/index.c +++ b/index.c @@ -45,14 +45,16 @@ MENU *create_menu(char **protected) { =20 void remove_menu(MENU *mymenu) { ITEM **item_list =3D menu_items(mymenu); - int i; + int i, cnt; =09 unpost_menu(mymenu); =09 - for (i=3D0;i