QEventDispatcherGlib: avoid potential integer overflow
There is a fact that the value of sizeof(int) may be smaller than the value of sizeof(qsizetype). Now that the data type of the return value for function QList::size() is qsizetype, we should change the datatype of activeNotifierPos from int to qsizetype in case that it may overflow in the function socketNotifierSourceDispatch. And we should also change the data type of the iteration variable i from int to qsizetype for the same reason in the function unregisterSocketNotifier. Change-Id: I017d184aa046684c0af1c17c94fb83611706ffa3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
cef270265f
commit
382c87333f
@ -29,7 +29,7 @@ struct GSocketNotifierSource
|
||||
{
|
||||
GSource source;
|
||||
QList<GPollFDWithQSocketNotifier *> pollfds;
|
||||
int activeNotifierPos;
|
||||
qsizetype activeNotifierPos;
|
||||
};
|
||||
|
||||
static gboolean socketNotifierSourcePrepare(GSource *, gint *timeout)
|
||||
@ -459,7 +459,7 @@ void QEventDispatcherGlib::unregisterSocketNotifier(QSocketNotifier *notifier)
|
||||
|
||||
Q_D(QEventDispatcherGlib);
|
||||
|
||||
for (int i = 0; i < d->socketNotifierSource->pollfds.size(); ++i) {
|
||||
for (qsizetype i = 0; i < d->socketNotifierSource->pollfds.size(); ++i) {
|
||||
GPollFDWithQSocketNotifier *p = d->socketNotifierSource->pollfds.at(i);
|
||||
if (p->socketNotifier == notifier) {
|
||||
// found it
|
||||
|
Loading…
x
Reference in New Issue
Block a user