Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-05-19 16:59:53 -0500
committerDan McGee <dan@archlinux.org>2011-05-19 16:59:53 -0500
commitf2c4e7e55220addef0581d1c38cc7363b5a0884c (patch)
treed9a2f05d7e1e97d8b7b8f8f1aec9983347a88721 /src
parentba467779bb0faa6ea81d91759c2224592091bbe3 (diff)
Coding style cleanups; add a null check
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'src')
-rw-r--r--src/pacman/pacman.c3
-rw-r--r--src/pacman/query.c12
2 files changed, 10 insertions, 5 deletions
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 8bdb216e..347d8af9 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -1265,8 +1265,9 @@ static void cl_to_log(int argc, char* argv[])
size += strlen(argv[i]) + 1;
}
char *cl_text = malloc(size);
- if(!cl_text)
+ if(!cl_text) {
return;
+ }
char *p = cl_text;
for(i = 0; i<argc-1; i++) {
strcpy(p, argv[i]);
diff --git a/src/pacman/query.c b/src/pacman/query.c
index 5d036881..6c63774f 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -60,16 +60,16 @@ static int search_path(char **filename, struct stat *bufptr)
char *envpath, *envpathsplit, *path, *fullname;
size_t flen;
- if ((envpath = getenv("PATH")) == NULL) {
+ if((envpath = getenv("PATH")) == NULL) {
return(-1);
}
- if ((envpath = envpathsplit = strdup(envpath)) == NULL) {
+ if((envpath = envpathsplit = strdup(envpath)) == NULL) {
return(-1);
}
flen = strlen(*filename);
- while ((path = strsep(&envpathsplit, ":")) != NULL) {
+ while((path = strsep(&envpathsplit, ":")) != NULL) {
size_t plen = strlen(path);
/* strip the trailing slash if one exists */
@@ -78,6 +78,10 @@ static int search_path(char **filename, struct stat *bufptr)
}
fullname = malloc(plen + flen + 2);
+ if(!fullname) {
+ free(envpath);
+ return(-1);
+ }
sprintf(fullname, "%s/%s", path, *filename);
if(lstat(fullname, bufptr) == 0) {
@@ -94,7 +98,7 @@ static int search_path(char **filename, struct stat *bufptr)
static void print_query_fileowner(const char *filename, pmpkg_t *info)
{
- if (!config->quiet) {
+ if(!config->quiet) {
printf(_("%s is owned by %s %s\n"), filename,
alpm_pkg_get_name(info), alpm_pkg_get_version(info));
} else {