Ticket #3927: mythsoap-null-terminate.2.patch

File mythsoap-null-terminate.2.patch, 1.7 KB (added by Daniel Burr, 17 years ago)

Updated patch to add a 'getError' method

  • mythmovies/ignyte/mythsoap.cpp

     
    1 #include <mythtv/mythcontext.h>
    2 
    31#include "mythsoap.h"
     2#include <iostream>
    43
    54void MythSoap::doSoapRequest(QString host, QString path, QString soapAction,
    65                             QString query)
     
    3534
    3635void MythSoap::httpDone(bool error)
    3736{
     37    using namespace std;
    3838    if (error)
    3939    {
    4040        cerr << "Error in mythsoap.o retrieving data: " << http.errorString() << endl << flush;
     41        m_error = true;
    4142    }
    4243    else
    4344    {
    44         m_data = http.readAll();
    45         //cout << "Data: " << m_data.data() << endl << flush;
     45        const Q_ULONG len = http.bytesAvailable();
     46        // QMemArray::assign() will own this so we don't have to delete it
     47        char* buffer = new char[len + 1];
     48        if(buffer) {
     49            http.readBlock(buffer, len);
     50            buffer[len] = '\0';
     51            m_data.assign(buffer, len + 1);
     52            //cout << "Data: " << m_data.data() << endl << flush;
     53        } else {
     54            cerr << "Failed to alloc memory in mythsoap.o" << endl;
     55        }
    4656    }
    4757    m_done = true;
    4858}
  • mythmovies/ignyte/mythsoap.h

     
    1212        QByteArray getResponseData();
    1313        bool isDone();
    1414        bool hasError();
     15        inline QString getError() const { return http.errorString(); }
    1516        MythSoap();
    1617
    1718    private: