summaryrefslogtreecommitdiffstats
path: root/lib/libalpm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/alpm.c2
-rw-r--r--lib/libalpm/alpm.h2
-rw-r--r--lib/libalpm/db.c4
3 files changed, 6 insertions, 2 deletions
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index f2a6270f..72b01a61 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -128,7 +128,7 @@ int SYMEXPORT alpm_release()
* @param treename the name of the repository
* @return a pmdb_t* on success (the value), NULL on error
*/
-pmdb_t SYMEXPORT *alpm_db_register(char *treename)
+pmdb_t SYMEXPORT *alpm_db_register(const char *treename)
{
ALPM_LOG_FUNC;
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 131ead3b..e2814281 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -148,7 +148,7 @@ alpm_list_t *alpm_option_get_syncdbs();
* Databases
*/
-pmdb_t *alpm_db_register(char *treename);
+pmdb_t *alpm_db_register(const char *treename);
int alpm_db_unregister(pmdb_t *db);
const char *alpm_db_get_name(pmdb_t *db);
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index e5489973..16b09a47 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -186,6 +186,10 @@ pmdb_t *_alpm_db_register(const char *treename)
/* make sure the database directory exists */
dbpath = alpm_option_get_dbpath();
+ if(!dbpath) {
+ _alpm_log(PM_LOG_WARNING, _("database path is undefined"));
+ RET_ERR(PM_ERR_DB_OPEN, NULL);
+ }
snprintf(path, PATH_MAX, "%s%s", dbpath, treename);
if(stat(path, &buf) != 0 || !S_ISDIR(buf.st_mode)) {
_alpm_log(PM_LOG_DEBUG, _("database directory '%s' does not exist, creating it"),