D13043: Properly sanitize input

Kai Uwe Broulik noreply at phabricator.kde.org
Wed May 23 09:03:47 UTC 2018


broulik added inline comments.

INLINE COMMENTS

> kconcatenaterowsproxymodel.cpp:70
>      const QAbstractItemModel *sourceModel = sourceIndex.model();
> +    if (!sourceModel)
> +        return {};

Coding style, braces also for single line statements

> kconcatenaterowsproxymodel.cpp:112
>      const QModelIndex sourceIndex = mapToSource(proxyIndex);
> -    return sourceIndex.model()->itemData(sourceIndex);
> +    return sourceIndex.isValid() ? sourceIndex.model()->itemData(sourceIndex) : QMap<int, QVariant>();
>  }

You can also use `{}` here, no? Also, I would prefer an early return rather than unary operator

> kconcatenaterowsproxymodel.cpp:151
>  {
> -    Q_ASSERT(row >= 0);
> -    Q_ASSERT(column >= 0);
> +    if(row < 0)
> +        return {};

Coding style. Also, check `parent.isValid() return {};` since this is a flat model?

REPOSITORY
  R275 KItemModels

REVISION DETAIL
  https://phabricator.kde.org/D13043

To: apol, #frameworks
Cc: broulik, kde-frameworks-devel, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20180523/80afa83c/attachment.html>


More information about the Kde-frameworks-devel mailing list