From edc83724ec0f22ccbb8a4d31238137096944d938 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 14 Jan 2006 17:32:50 +0000 Subject: Extra m_sql field checking git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2789 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/extra/m_sql.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/modules/extra/m_sql.cpp b/src/modules/extra/m_sql.cpp index 6b31ce871..dafd76118 100644 --- a/src/modules/extra/m_sql.cpp +++ b/src/modules/extra/m_sql.cpp @@ -115,15 +115,23 @@ class SQLConnection if (row) { unsigned int field_count = 0; + MYSQL_FIELD *fields = mysql_fetch_fields(res); if(mysql_field_count(&connection) == 0) return thisrow; - MYSQL_FIELD *fields = mysql_fetch_fields(res); - while (field_count < mysql_field_count(&connection)) + if (fields && mysql_field_count(&connection)) { - thisrow[std::string(fields[field_count].name)] = std::string(row[field_count]); - field_count++; + while (field_count < mysql_field_count(&connection)) + { + if (fields[field_count] && fields[field_count].name && row[field_count]) + { + std::string a = (fields[field_count].name ? fields[field_count].name : ""); + std::string b = (row[field_count] ? row[field_count] : ""); + thisrow[a] = b; + field_count++; + } + } + return thisrow; } - return thisrow; } } return thisrow; -- cgit v1.2.3