Fikset segfaults.

This commit is contained in:
David Kaasen 2017-09-28 15:21:02 +00:00
parent 07698b55a8
commit 33c3ba82e2
2 changed files with 4 additions and 5 deletions

View File

@ -209,7 +209,7 @@ list(MYSQL *pmysql)
usr_groups = get_group_names(&numgroups);
cp = usr_groups;
while (*cp) { // itererer over alle grupper en person er med i
while (cp && *cp) { // itererer over alle grupper en person er med i
if (*cp == NULL)
break;
@ -625,12 +625,11 @@ main(int argc, char *argv[])
if ((command == c_show) && (argc == 2)) {
dblist = list(&mysql);
p = dblist;
while (*p) {
while (p && *p) {
show(&mysql, *p);
free(*p);
p++;
}
free(*p);
free(dblist);
}
else {

View File

@ -191,7 +191,7 @@ list(MYSQL *pmysql)
usrgroups = get_group_names(&numgroups);
cp = usrgroups;
while (*cp) {
while (cp && *cp) {
end = strmov(end, " OR user='");
end += mysql_real_escape_string(pmysql, end, *cp, strlen(*cp));
end = strmov(end, "' OR user LIKE '");
@ -290,7 +290,7 @@ main(int argc, char *argv[])
{
dblist = list(&mysql);
p = dblist;
while (*p)
while (p && *p)
{
show(&mysql, *p);
free(*p);