Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. ERROR:ASSERT: "uint(i) < uint(size())"
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 9.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    isan
    wrote on last edited by isan
    #1

    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;
    
        
    }
    
    1 Reply Last reply
    0
    • M Offline
      M Offline
      mostefa
      wrote on last edited by
      #2

      @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

      I 1 Reply Last reply
      3
      • M mostefa

        @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

        I Offline
        I Offline
        isan
        wrote on last edited by
        #3

        @mostefa
        i check with

        if (ResponseData.size()!=0)
        

        and this line

        unsigned chara=ResponseData.at(5);
        

        means from byte 5 of ResponseData get size

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mostefa
          wrote on last edited by
          #4

          @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){
          ..
          ..
          ..
          }
          }
          
          I 1 Reply Last reply
          4
          • M mostefa

            @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){
            ..
            ..
            ..
            }
            }
            
            I Offline
            I Offline
            isan
            wrote on last edited by
            #5

            @mostefa
            tnx error is gone

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mostefa
              wrote on last edited by
              #6

              @isan

              You are welcome :)

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved