[pacman-dev] [PATCH] alpm_list_remove treat NULL needle as "nothing"
From c44fec0058d8a69d29eeb947698bfaf165a6a080 Mon Sep 17 00:00:00 2001 From: Nagy Gabor <ngaba@bibl.u-szeged.hu> Date: Wed, 16 Jul 2008 15:57:08 +0200 Subject: [PATCH] alpm_list_remove treat NULL needle as "nothing" So if you want to remove NULL needle from a list, alpm_list_remove will return with "not found". Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> --- lib/libalpm/alpm_list.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/lib/libalpm/alpm_list.c b/lib/libalpm/alpm_list.c index 8756740..9889503 100644 --- a/lib/libalpm/alpm_list.c +++ b/lib/libalpm/alpm_list.c @@ -302,6 +302,10 @@ alpm_list_t SYMEXPORT *alpm_list_remove(alpm_list_t *haystack, const void *needl *data = NULL; } + if(needle == NULL) { + return(haystack); + } + while(i) { if(i->data == NULL) { continue; -- 1.5.6.2
From c44fec0058d8a69d29eeb947698bfaf165a6a080 Mon Sep 17 00:00:00 2001 From: Nagy Gabor <ngaba@bibl.u-szeged.hu> Date: Wed, 16 Jul 2008 15:57:08 +0200 Subject: [PATCH] alpm_list_remove treat NULL needle as "nothing"
So if you want to remove NULL needle from a list, alpm_list_remove will return with "not found".
Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
After this patch my previous "fix segfault" patch is not needed. But if you like "safe programming", you will like that patch too. Bye
On Wed, Jul 16, 2008 at 4:03 PM, Nagy Gabor <ngaba@bibl.u-szeged.hu> wrote:
After this patch my previous "fix segfault" patch is not needed. But if you like "safe programming", you will like that patch too.
Yeah, both look fine.
participants (2)
-
Nagy Gabor
-
Xavier