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); usr_groups = get_group_names(&numgroups);
cp = usr_groups; 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) if (*cp == NULL)
break; break;
@ -625,12 +625,11 @@ main(int argc, char *argv[])
if ((command == c_show) && (argc == 2)) { if ((command == c_show) && (argc == 2)) {
dblist = list(&mysql); dblist = list(&mysql);
p = dblist; p = dblist;
while (*p) { while (p && *p) {
show(&mysql, *p); show(&mysql, *p);
free(*p); free(*p);
p++; p++;
} }
free(*p);
free(dblist); free(dblist);
} }
else { else {

View File

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