Ignore:
Timestamp:
Jun 25, 2014 12:58:19 AM (7 years ago)
Author:
ldelgass
Message:

Fix crash bug in user errors: was returning pointer to temporary. Return a
copy of string object from getUserMessages instead of pointer.

Location:
trunk/packages/vizservers/vtkvis
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/vtkvis/RendererCmd.cpp

    r4371 r4422  
    1312213122            std::ostringstream oss;
    1312313123            oss << "nv>viserror -type internal_error -token " << g_stats.nCommands << " -bytes " << nBytes << "\n" << string;
    13124             nBytes = oss.str().length();
     13124            std::string ostr = oss.str();
     13125            nBytes = ostr.length();
    1312513126
    1312613127#ifdef USE_THREADS
    13127             queueResponse(clientData, oss.str().c_str(), nBytes, Response::VOLATILE, Response::ERROR);
     13128            queueResponse(clientData, ostr.c_str(), nBytes, Response::VOLATILE, Response::ERROR);
    1312813129#else
    13129             if (write(fdOut, oss.str().c_str(), nBytes) < 0) {
     13130            if (write(fdOut, ostr.c_str(), nBytes) < 0) {
    1313013131                ERROR("write failed: %s", strerror(errno));
    1313113132                return -1;
     
    1313513136    }
    1313613137
    13137     string = getUserMessages();
    13138     nBytes = strlen(string);
     13138    std::string msg = getUserMessages();
     13139    nBytes = msg.length();
    1313913140    if (nBytes > 0) {
     13141        string = msg.c_str();
    1314013142        TRACE("userError=(%s)", string);
    1314113143
    1314213144        std::ostringstream oss;
    1314313145        oss << "nv>viserror -type error -token " << g_stats.nCommands << " -bytes " << nBytes << "\n" << string;
    13144         nBytes = oss.str().length();
     13146        std::string ostr = oss.str();
     13147        nBytes = ostr.length();
    1314513148
    1314613149#ifdef USE_THREADS
    13147         queueResponse(clientData, oss.str().c_str(), nBytes, Response::VOLATILE, Response::ERROR);
     13150        queueResponse(clientData, ostr.c_str(), nBytes, Response::VOLATILE, Response::ERROR);
    1314813151#else
    13149         if (write(fdOut, oss.str().c_str(), nBytes) < 0) {
     13152        if (write(fdOut, ostr.c_str(), nBytes) < 0) {
    1315013153            ERROR("write failed: %s", strerror(errno));
    1315113154            return -1;
  • trunk/packages/vizservers/vtkvis/Trace.cpp

    r3615 r4422  
    8888}
    8989
    90 const char *
     90std::string
    9191VtkVis::getUserMessages()
    9292{
    93     return g_UserErrorString.str().c_str();
     93    return g_UserErrorString.str();
    9494}
    9595
  • trunk/packages/vizservers/vtkvis/Trace.h

    r3615 r4422  
    99#define VTKVIS_TRACE_H
    1010
     11#include <string>
     12
    1113#include <syslog.h>
    1214
     
    1517extern void logUserMessage(const char* format, ...);
    1618
    17 extern const char *getUserMessages();
     19extern std::string getUserMessages();
    1820
    1921extern void clearUserMessages();
Note: See TracChangeset for help on using the changeset viewer.