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. QVector::operator[] segment violation mysterious.
QtWS25 Last Chance

QVector::operator[] segment violation mysterious.

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 630 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.
  • C Offline
    C Offline
    Charlie_Hdz
    wrote on last edited by
    #1

    Hello.

    I'm working on a Encryption Algorithms test.

    Specifically, this code give me the next problems:

    @QString Crypto::unpermute(const QString& str){
    QString sKey;
    sKey.setNum(m_usKey);

    const int rows=str.length()/sKey.length();

    QVector<QByteArray> seqTable;
    int nCount=0;
    int nCountPos=0;
    int posKeeper=0;
    QVector<QChar> keySorter;

    for(int i=0; i<sKey.size();++i)
    keySorter.push_back(sKey[i]);
    qSort(keySorter);

    seqTable.reserve(sKey.length());

    //Fill Vector<QBA>
    for(int i=0;i<sKey.length();i++){
    QByteArray qbaBuffer;
    //Per QBA
    for(int j=0;j<rows;j++){
    qbaBuffer+=str[nCount];
    ++nCount;
    }
    //Insert QBA into its respective place
    for(int k=0;k<sKey.length();k++){
    if(keySorter[nCountPos]==sKey[k]){
    posKeeper=k;
    seqTable[posKeeper]=qbaBuffer;
    }
    }
    }

    QString dest;
    //Read and store uncryptying string
    for(int k=0;k<rows;k++)
    for(int l=0;l<sKey.length();l++)
    dest+=seqTable[l][k];

    return dest;
    }@

    !http://i1344.photobucket.com/albums/p656/Charlie_Hdz/03_zpsc2b42b7b.png(A)!
    (This is the output of Qmake;make)

    (Using QMake Debugger and arriving to this instruction <seqTable[posKeeper]=qbaBuffer;> , QtCreator send me this message:)
    !http://i1344.photobucket.com/albums/p656/Charlie_Hdz/02_zpsac8d978a.png(2)!

    Any help would be appreciated.

    Kind Regards,
    Enrique Hernandez
    gearstech.com.mx
    chernandez@gearstech.com.mx

    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