Ticket #6999: libs_libmythupnp-check-return

File libs_libmythupnp-check-return, 1.2 KB (added by Erik Hovland <erik@…>, 11 years ago)

Check query.next()

Line 
1Check the return values of function calls.
2
3From: Erik Hovland <erik@hovland.org>
4
5
6---
7
8 mythtv/libs/libmythupnp/upnpcds.cpp |   10 ++++------
9 1 files changed, 4 insertions(+), 6 deletions(-)
10
11
12diff --git a/mythtv/libs/libmythupnp/upnpcds.cpp b/mythtv/libs/libmythupnp/upnpcds.cpp
13index 2f36145..eeb5ed5 100644
14--- a/mythtv/libs/libmythupnp/upnpcds.cpp
15+++ b/mythtv/libs/libmythupnp/upnpcds.cpp
16@@ -1146,9 +1146,8 @@ int UPnpCDSExtension::GetDistinctCount( UPnpCDSRootInfo *pInfo )
17 
18         if (query.exec() && query.size() > 0)
19         {
20-            query.next();
21-
22-            nCount = query.value(0).toInt();
23+            if (query.next())
24+                nCount = query.value(0).toInt();
25         }
26     }
27 
28@@ -1179,9 +1178,8 @@ int UPnpCDSExtension::GetCount( const QString &sColumn, const QString &sKey )
29 
30         if (query.exec() && query.size() > 0)
31         {
32-            query.next();
33-
34-            nCount = query.value(0).toInt();
35+            if (query.next())
36+                nCount = query.value(0).toInt();
37         }
38         VERBOSE(VB_UPNP+VB_EXTRA, "UPnpCDSExtension::GetCount() - " +
39                                   sSQL + " = " + QString::number(nCount));