]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_sql.cpp
Updated copyrights in headers etc using perl inplace edit
[user/henk/code/inspircd.git] / src / modules / extra / m_sql.cpp
index 6b31ce87122bc55d03fcfb36fdd8fcb9e9479367..de96c5a9309898e66d453cfa792fc24b0c18ec35 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
+ *  InspIRCd is copyright (C) 2002-2004 ChatSpike-Dev.
  *                       E-mail:
  *                <brain@chatspike.net>
  *               <Craig@chatspike.net>
@@ -115,15 +115,20 @@ 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))
+                                       {
+                                               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;