ERROR:ASSERT: "uint(i) < uint(size())"



  • after call this function program send this error ASSERT: "uint(i) < uint(size())" in file /root/raspi/qt5pi/include/QtCore/qbytearray.h, line 470 and Aborted
    why this happend?

    QByteArray  GetResponse::getEPC(QByteArray ResponseData){
        QByteArray EPC;
        if(ResponseData.at(3)==0x01){
            if (ResponseData.size()!=0){
                unsigned char a=ResponseData.at(5);
                int maxCard=a;
                int i=7;
                int max=19;
                int j=0;
                for (int card = 0; card < maxCard; card++) {
                    QByteArray temp;
                    j=0;
                    if(i+12<ResponseData.size()){
                        for (i;i < max; i++) {
                            temp.append(ResponseData.at(i));
                            j+=1;
                        }
                    }
                    if(temp.size()>0)
                        EPC.append(temp);
                    i+=2;
                    max+=14;
                }//end of for cards
            }
    }
          
                return EPC;
    
        
    }
    


  • @isan

    Here :

    unsigned char a=ResponseData.at(5);
    

    You are not sure that ResponseData.size is upper than 5 , than you have to do something like this:

    if(ResponseData.size >= 5)
    {
          unsigned char a=ResponseData.at(5);
    }
    

    I think that this is your problem



  • @mostefa
    i check with

    if (ResponseData.size()!=0)
    

    and this line

    unsigned chara=ResponseData.at(5);
    

    means from byte 5 of ResponseData get size



  • @isan

    Ok but for your first test ?

    if(ResponseData.at(3)==0x01){
    

    I think that you have to do something like this:

    if(ResponseData.size > 3 )// it is really important to check that your DataResponse size is upper than 3
    {
        if(ResponseData.at(3) == 0x01){
    ..
    ..
    ..
    }
    }
    


  • @mostefa
    tnx error is gone



  • @isan

    You are welcome :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.