From 88644e181db49f3f94e6891166823fd5f46acbcc Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 25 Jul 2011 10:05:36 -0500 Subject: Fix group selection entry for large inputs Hardcoding anything always ends up burning you, and the arbitrary length of 64 here did just that. Add the ability to reallocate the readline buffer for longer inputs if necessary, and add other error checking as approprate. This also plugs one small memory leak of the group processing code selection array. Addresses FS#24253. Signed-off-by: Dan McGee --- src/pacman/sync.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/pacman/sync.c') diff --git a/src/pacman/sync.c b/src/pacman/sync.c index c56934b6..6962306a 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -644,7 +644,15 @@ static int process_group(alpm_list_t *dbs, char *group) group); select_display(pkgs); char *array = malloc(count); - multiselect_question(array, count); + if(!array) { + ret = 1; + goto cleanup; + } + if(multiselect_question(array, count)) { + ret = 1; + free(array); + goto cleanup; + } int n = 0; for(i = pkgs; i; i = alpm_list_next(i)) { if(array[n++] == 0) @@ -657,6 +665,7 @@ static int process_group(alpm_list_t *dbs, char *group) goto cleanup; } } + free(array); } else { for(i = pkgs; i; i = alpm_list_next(i)) { pmpkg_t *pkg = alpm_list_getdata(i); -- cgit v1.2.3-24-g4f1b