From 5aa873edb696bbf678cbb57df43d90e23d562179 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 5 Jan 2008 17:34:10 -0600 Subject: sync.c: add sanity check so we don't dereference a null pointer Originally noticed in FS#9024, but was fixed in previous changes anyway. However, it doesn't hurt to still check it. Also add a pactest from Chantry Xavier for the original problem to ensure we can't reproduce it. Signed-off-by: Dan McGee --- lib/libalpm/sync.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index dd54ce6c..ec4af9f4 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -570,12 +570,14 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync } if(rmpkg) { pmsyncpkg_t *rsync = _alpm_sync_find(trans->packages, rmpkg); - void *vpkg; - _alpm_log(PM_LOG_DEBUG, "removing '%s' from target list\n", - rsync->pkg->name); - trans->packages = alpm_list_remove(trans->packages, rsync, - syncpkg_cmp, &vpkg); - _alpm_sync_free(vpkg); + if(rsync) { + void *vpkg; + _alpm_log(PM_LOG_DEBUG, "removing '%s' from target list\n", + rsync->pkg->name); + trans->packages = alpm_list_remove(trans->packages, rsync, + syncpkg_cmp, &vpkg); + _alpm_sync_free(vpkg); + } continue; } } -- cgit v1.2.3-24-g4f1b