Ticket #6998: libs_libmythdb-check-return

File libs_libmythdb-check-return, 1.0 KB (added by Erik Hovland <erik@…>, 15 years ago)

Check query.next()

Line 
1Check the return value of query.next().
2
3From: Erik Hovland <erik@hovland.org>
4
5This may be non-issue since the size of the query was already
6checked. But it seems that query.next() is often checked. This
7one in GetSettingOnHost() wasn't. So I added an if to do that.
8---
9
10 mythtv/libs/libmythdb/mythdb.cpp |    8 +++++---
11 1 files changed, 5 insertions(+), 3 deletions(-)
12
13
14diff --git a/mythtv/libs/libmythdb/mythdb.cpp b/mythtv/libs/libmythdb/mythdb.cpp
15index 61c9928..a0d789a 100644
16--- a/mythtv/libs/libmythdb/mythdb.cpp
17+++ b/mythtv/libs/libmythdb/mythdb.cpp
18@@ -413,9 +413,11 @@ QString MythDB::GetSettingOnHost(const QString &key, const QString &host,
19 
20             if (query.exec() && query.isActive() && query.size() > 0)
21             {
22-                query.next();
23-                value = query.value(0).toString();
24-                found = true;
25+                if (query.next())
26+                {
27+                    value = query.value(0).toString();
28+                    found = true;
29+                }
30             }
31         }
32         else