Buffer Overrun using QLibrary!!!!



  • Setup:
    QT 4.7.4 , MSVC2010 (IDE)

    Step 1: I have created a win32 dll with name Temp.dll in which i have linked QT libraries & also added required include files so that i can also use QT datatypes in that dll.
    In Temp.dll I have exported a class & the class has one function with following prototype & definition
    @
    QString Data(QString data)
    {
    return data;
    }
    @

    Step 2: Now I have created one Sample QT Appplication code for same is given below but when I am trying to call the above function in this application in for loop after 2-3 iterations of for loop it is crashing & giving following error message

    A buffer overrun has occurred in LoadLibrary.exe which has corrupted the program's internal state. Press Break to debug the program or Continue to terminate the program.

    For more details please see Help topic 'How to debug Buffer Overrun Issues'.

    @Sample App Code:

    #include <QLibrary>
    #include <QString>
    #include <qdebug.h>

    //Function Pointers
    typedef QString (*Data)(QString);

    int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);
    bool bLoaded = false;
    //Load win32 Export Library
    QLibrary lib("Temp.dll");
    bLoaded = lib.load();
    Data data= (Data) lib.resolve("Data");
    if(bLoaded)
    {
    for(int i = 0;i<100; i++)
    {
    QString strstring = "Test";
    if(lib.isLoaded())
    QString strReturnVal = data(strstring);
    }
    }
    else
    {
    QString str = "Failed to load Temp library";
    }
    bool bUnLoad = lib.unload();

        return a.exec&#40;&#41;; 
    

    } @



  • This is the third thread now. Please stick to the "thread":http://developer.qt.nokia.com/forums/viewthread/13631/ "you" have already created on this topic.



  • Closed. See Lukas link for the thread to continue in.


Log in to reply
 

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