Menu

Condition 'ba.isEmpty()' is always false" false positiv with QByteArray

2022-12-02
2022-12-02
  • Vincas Dargis

    Vincas Dargis - 2022-12-02

    With Cppcheck 2.9 I get false positive within Qt 5.15 application code:

    Condition 'ba.isEmpty()' is always false
    

    For this function:

    QImage deserializeImage(const QVariant &data) {
    
        if (data.isNull())
            return QImage{};
    
        const QByteArray ba{data.toByteArray()};
        if (ba.isEmpty())
            return QImage{};
    
        return QImage::fromData(ba, "PNG");
    }
    

    I've attached example application project.

     
  • CHR

    CHR - 2022-12-02

    Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/11417

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.