2
0
Эх сурвалжийг харах

- check the type of table_version result (reported by Ryan (Matty <[email protected]>))
- free mysql connection from pool only when found


git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@950 689a6050-402a-0410-94f2-e92a70836424

Daniel-Constantin Mierla 19 жил өмнө
parent
commit
b5887fbfda
1 өөрчлөгдсөн 13 нэмэгдсэн , 2 устгасан
  1. 13 2
      lib/srdb1/db.c

+ 13 - 2
lib/srdb1/db.c

@@ -179,12 +179,23 @@ int table_version(db_func_t* dbf, db_con_t* connection, const str* table)
 	}
 
 	if (RES_ROW_N(res) == 0) {
-		DBG("table_version(): No row for table %.*s found\n", table->len, ZSW(table->s));
+		DBG("table_version(): No row for table %.*s found\n", table->len,
+				ZSW(table->s));
 		return 0;
 	}
 
 	if (RES_ROW_N(res) != 1) {
-		LOG(L_ERR, "table_version(): Invalid number of rows received: %d, %.*s\n", RES_ROW_N(res), table->len, ZSW(table->s));
+		LOG(L_ERR,
+			"table_version(): Invalid number of rows received: %d, %.*s\n",
+			RES_ROW_N(res), table->len, ZSW(table->s));
+		dbf->free_result(connection, res);
+		return -1;
+	}
+
+	if (VAL_TYPE(ROW_VALUES(RES_ROWS(res)))!=DB_INT) {
+		LOG(L_ERR,
+			"table_version(): Invalid type for table version: %d\n",
+			VAL_TYPE(ROW_VALUES(RES_ROWS(res))));
 		dbf->free_result(connection, res);
 		return -1;
 	}