Coder Social home page Coder Social logo

Crash in ReplaceCommand::redo about qhexview HOT 7 CLOSED

dax89 avatar dax89 commented on July 26, 2024
Crash in ReplaceCommand::redo

from qhexview.

Comments (7)

Dax89 avatar Dax89 commented on July 26, 2024

Starting from this commit: 2a662d4

I have rewrited QHexEditData from scratch in order to support big files (and generic QIODevice objects too).
Now, QHexEditData's constructor is private, and you can load a generic I/O Device or an In-Memory buffer using these three methods:

  • QHexEditData::fromFile()
  • QHexEditData::fromBuffer()
  • QHexEditData::fromDevice()

By looking at your source code, I have seen in setupInstructionEncoding() method these lines of code:

void MainWindow::setupInstructionEncoding()
{
    char buf[32];
    memset(buf, 0, sizeof(buf));

    QBuffer *encodingBuffer;

    encodingBuffer = new QBuffer();
    encodingBuffer->open(QBuffer::ReadWrite);
    encodingBuffer->write(buf, sizeof(buf));

    m_encodingData = new QHexEditData(encodingBuffer);

   ...
}

which can be rewritten as:

void MainWindow::setupInstructionEncoding()
{
    /* Create a buffer with length = 32, and fill it with 0x00 */
    QByteArray buf(32, 0x00);

    /* Associate this buffer with QHexEditData, and take the ownership */
    m_encodingData = QHexEditData::fromBuffer(buf);

   ...
}

from qhexview.

SimonKagstrom avatar SimonKagstrom commented on July 26, 2024

OK, good to hear - I'll take a look at that.

That said, since internalInsert and internalRemove can return NULL, so I think it would be good to check the return value from them.

from qhexview.

SimonKagstrom avatar SimonKagstrom commented on July 26, 2024

With the fromBuffer() stuff, I can now compile, but I still get the crash.

What I do is basically

void MainWindow::setupInstructionEncoding()
{
    QByteArray buf(32, 0x0);

    m_encodingData = QHexEditData::fromMemory(buf);
        [...]
    m_encodingHexEdit = new QHexEdit(m_ui->instructionEncodingLineEdit);
    m_encodingHexEdit->setData(m_encodingData);
}

void MainWindow::updateInstructionEncoding(const IInstruction* insn)
{
    uint8_t buf[32];

        [... fill in buf]
    m_encodingData->replace(0, 32, QByteArray((const char *)buf, sizeof(buf)));
}

where updateInstructionEncoding is called to fill in the current position. I get a crash in replace(), and get the same behavior when using remove() + insert().

from qhexview.

Dax89 avatar Dax89 commented on July 26, 2024

Ok, I can reproduce this bug, I will fix it in short time!
Sorry for this issue :)

from qhexview.

Dax89 avatar Dax89 commented on July 26, 2024

The commit e7eb910 should fix the bug.

Let me know if it works now.

from qhexview.

SimonKagstrom avatar SimonKagstrom commented on July 26, 2024

Yes, after that commit it works again.

Thanks!

On Sat, Jan 18, 2014 at 6:35 PM, Antonio Davide [email protected]:

The commit e7eb910e7eb91051706c3e02a02e979d6e9b02cc8fcc729should fix the bug.

Let me know if it works now.


Reply to this email directly or view it on GitHubhttps://github.com//issues/3#issuecomment-32687448
.

from qhexview.

Dax89 avatar Dax89 commented on July 26, 2024

Great!

from qhexview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.