--- vmysql.c.old	Mon Oct  9 17:59:46 2000
+++ vmysql.c	Mon Oct  9 17:56:51 2000
@@ -35,7 +35,7 @@
 
 static int is_open = 0;
 static MYSQL mysql;
-static MYSQL_RES *res;
+static MYSQL_RES *res, *res1=NULL;
 static MYSQL_ROW row;
 
 #define SQL_BUF_SIZE 600
@@ -422,13 +422,15 @@
 		if ( sortit == 1 ) {
 			strcat( SqlBuf, " order by pw_name");
 		}
-
+		if (res1) mysql_free_result(res1);
+		res1=NULL;
+		
 		if (mysql_query(&mysql,SqlBuf)) {
 			printf("vsql_getpw: failed select\n");
 			return(NULL);
 		}
 
-		if (!(res = mysql_use_result(&mysql))) {
+		if (!(res1 = mysql_use_result(&mysql))) {
 			printf("vsql_getpw: store result failed\n");
 			return(NULL);
 		}
@@ -440,7 +442,7 @@
 	pwent.pw_dir    = IDir;
 	pwent.pw_shell  = IShell;
 	
-	if ((row = mysql_fetch_row(res)) != NULL) {
+	if ((row = mysql_fetch_row(res1)) != NULL) {
 		scopy(pwent.pw_name,row[0],SMALL_BUFF);
 		scopy(pwent.pw_passwd,row[1],SMALL_BUFF);
 		pwent.pw_uid    = atoi(row[2]);
@@ -450,7 +452,8 @@
 		scopy(pwent.pw_shell, row[6],SMALL_BUFF);
 		return(&pwent);
 	}
-	mysql_free_result(res);
+	mysql_free_result(res1);
+	res1=NULL;
 	return(NULL);
 }
 
