From 65c18807350b2bedff0546b839fd5cd0004a6d4f Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Thu, 19 May 2011 17:42:22 -0500 Subject: Bail early if we don't have a valid lockfile path This addresses FS#24292. If one does the bad thing of not checking pm_errno after calling set_dbpath(), you may not realize the initialization process went wrong and calling trans_init() resulted in a segfault. If we don't have a lockfile path, bail out and have trans_init() fail. Also remove a ALPM_LOG_FUNC call that was causing pm_errno to return "no handle"; this was due to a log call in the handle setup (whereby the log attempts to use a callback attached to the handle). Signed-off-by: Dan McGee --- lib/libalpm/handle.c | 2 -- lib/libalpm/trans.c | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'lib/libalpm') diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c index d8ce9fd2..586aad1e 100644 --- a/lib/libalpm/handle.c +++ b/lib/libalpm/handle.c @@ -46,8 +46,6 @@ pmhandle_t *_alpm_handle_new() { pmhandle_t *handle; - ALPM_LOG_FUNC; - CALLOC(handle, 1, sizeof(pmhandle_t), RET_ERR(PM_ERR_MEMORY, NULL)); return(handle); diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index 7affbfbd..bf9ef722 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -58,6 +58,8 @@ static int make_lock(pmhandle_t *handle) int fd; char *dir, *ptr; + ASSERT(handle->lockfile != NULL, return -1); + /* create the dir of the lockfile first */ dir = strdup(handle->lockfile); ptr = strrchr(dir, '/'); @@ -110,7 +112,6 @@ int SYMEXPORT alpm_trans_init(pmtransflag_t flags, /* Sanity checks */ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); - ASSERT(handle->trans == NULL, RET_ERR(PM_ERR_TRANS_NOT_NULL, -1)); /* lock db */ -- cgit v1.2.3-24-g4f1b From e711e5b9501adcb692c65e7d358ae5b0e5bcfb57 Mon Sep 17 00:00:00 2001 From: Pang Yan Han Date: Tue, 24 May 2011 11:25:13 +0800 Subject: alpm_list: fix typo in doxygen comment Signed-off-by: Pang Yan Han Signed-off-by: Dan McGee --- lib/libalpm/alpm_list.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libalpm') diff --git a/lib/libalpm/alpm_list.c b/lib/libalpm/alpm_list.c index f0619bcd..42ef367a 100644 --- a/lib/libalpm/alpm_list.c +++ b/lib/libalpm/alpm_list.c @@ -287,7 +287,7 @@ alpm_list_t SYMEXPORT *alpm_list_msort(alpm_list_t *list, size_t n, alpm_list_fn /** * @brief Remove an item from the list. - * item is not freed; this is the responsiblity of the caller. + * item is not freed; this is the responsibility of the caller. * * @param haystack the list to remove the item from * @param item the item to remove from the list -- cgit v1.2.3-24-g4f1b