lsblk: fix null pointer dereferences
Both catched with -Wnull-dereference compiler option: Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
2859592ecb
commit
e361253e88
|
@ -203,7 +203,8 @@ int lsblk_device_is_last_parent(struct lsblk_device *dev, struct lsblk_device *p
|
|||
struct lsblk_devdep *dp = list_last_entry(
|
||||
&dev->parents,
|
||||
struct lsblk_devdep, ls_parents);
|
||||
|
||||
if (!dp)
|
||||
return 0;
|
||||
return dp->parent == parent;
|
||||
}
|
||||
|
||||
|
|
|
@ -747,7 +747,7 @@ static char *device_get_data(
|
|||
case COL_OWNER:
|
||||
{
|
||||
struct stat *st = device_get_stat(dev);
|
||||
struct passwd *pw = st ? NULL : getpwuid(st->st_uid);
|
||||
struct passwd *pw = st ? getpwuid(st->st_uid) : NULL;
|
||||
if (pw)
|
||||
str = xstrdup(pw->pw_name);
|
||||
break;
|
||||
|
@ -755,7 +755,7 @@ static char *device_get_data(
|
|||
case COL_GROUP:
|
||||
{
|
||||
struct stat *st = device_get_stat(dev);
|
||||
struct group *gr = st ? NULL : getgrgid(st->st_gid);
|
||||
struct group *gr = st ? getgrgid(st->st_gid) : NULL;
|
||||
if (gr)
|
||||
str = xstrdup(gr->gr_name);
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue