From cd5f64daf7a6a9af42ec823e76a7b7a82855527c Mon Sep 17 00:00:00 2001 From: brain Date: Sun, 23 Jul 2006 10:30:33 +0000 Subject: Adjust m_mysql to match the assumed behaviour of m_pgsql exactly, e.g. when there are now rows left return an empty row Fix mistake which required a reference to be freed (?!) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4523 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/extra/m_mysql.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index daf59a5d9..a2d30917a 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -206,6 +206,7 @@ class MySQLresult : public SQLresult std::vector colnames; std::vector fieldlists; SQLfieldMap* fieldmap; + SQLfieldMap fieldmap2; int rows; int cols; public: @@ -325,15 +326,18 @@ class MySQLresult : public SQLresult virtual SQLfieldMap& GetRowMap() { - fieldmap = new SQLfieldMap(); - - for (int i = 0; i < cols; i++) + fieldmap2 = SQLfieldMap(); + + if (currentrow < rows) { - fieldmap->insert(std::make_pair(colnames[cols],GetValue(currentrow, i))); + for (int i = 0; i < cols; i++) + { + fieldmap2.insert(std::make_pair(colnames[cols],GetValue(currentrow, i))); + } + currentrow++; } - currentrow++; - return *fieldmap; + return fieldmap2; } virtual SQLfieldList* GetRowPtr() @@ -344,12 +348,15 @@ class MySQLresult : public SQLresult virtual SQLfieldMap* GetRowMapPtr() { fieldmap = new SQLfieldMap(); - - for (int i = 0; i < cols; i++) + + if (currentrow < rows) { - fieldmap->insert(std::make_pair(colnames[cols],GetValue(currentrow, i))); + for (int i = 0; i < cols; i++) + { + fieldmap->insert(std::make_pair(colnames[cols],GetValue(currentrow, i))); + } + currentrow++; } - currentrow++; return fieldmap; } -- cgit v1.2.3