Changeset 4422


Ignore:
Timestamp:
Jun 25, 2014 12:58:19 AM (9 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
Files:
9 edited

Legend:

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

    r4383 r4422  
    18521852    }
    18531853
    1854     string = getUserMessages();
    1855     nBytes = strlen(string);
     1854    std::string msg = getUserMessages();
     1855    nBytes = msg.length();
    18561856    if (nBytes > 0) {
     1857        string = msg.c_str();
    18571858        TRACE("userError=(%s)", string);
    18581859
    18591860        std::ostringstream oss;
    18601861        oss << "nv>viserror -type error -token " << g_stats.nCommands << " -bytes " << nBytes << "\n" << string;
    1861         nBytes = oss.str().length();
    1862 
    1863         if (queueResponse(oss.str().c_str(), nBytes, Response::VOLATILE, Response::ERROR) < 0) {
     1862        std::string ostr = oss.str();
     1863        nBytes = ostr.length();
     1864
     1865        if (queueResponse(ostr.c_str(), nBytes, Response::VOLATILE, Response::ERROR) < 0) {
    18641866            return -1;
    18651867        }
  • trunk/packages/vizservers/geovis/Trace.cpp

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

    r3998 r4422  
    99#define GEOVIS_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();
  • trunk/packages/vizservers/nanovis/Command.cpp

    r4368 r4422  
    23152315    }
    23162316
    2317     string = getUserMessages();
    2318     nBytes = strlen(string);
     2317    std::string msg = getUserMessages();
     2318    nBytes = msg.length();
    23192319    if (nBytes > 0) {
     2320        string = msg.c_str();
    23202321        TRACE("userError=(%s)", string);
    23212322
    23222323        std::ostringstream oss;
    23232324        oss << "nv>viserror -type error -token " << g_stats.nCommands << " -bytes " << nBytes << "\n" << string;
    2324         nBytes = oss.str().length();
     2325        std::string ostr = oss.str();
     2326        nBytes = ostr.length();
    23252327
    23262328#ifdef USE_THREADS
    2327         queueResponse(oss.str().c_str(), nBytes, Response::VOLATILE, Response::ERROR);
     2329        queueResponse(ostr.c_str(), nBytes, Response::VOLATILE, Response::ERROR);
    23282330#else
    2329         if (write(fdOut, oss.str().c_str(), nBytes) < 0) {
     2331        if (write(fdOut, ostr.c_str(), nBytes) < 0) {
    23302332            ERROR("write failed: %s", strerror(errno));
    23312333            return -1;
  • trunk/packages/vizservers/nanovis/Trace.cpp

    r3605 r4422  
    9090}
    9191
    92 const char *
     92std::string
    9393nv::getUserMessages()
    9494{
    95     return g_UserErrorString.str().c_str();
     95    return g_UserErrorString.str();
    9696}
    9797
  • trunk/packages/vizservers/nanovis/Trace.h

    r3613 r4422  
    88#ifndef NV_TRACE_H
    99#define NV_TRACE_H
     10
     11#include <string>
    1012
    1113#include <GL/glew.h>
     
    2224extern void logUserMessage(const char* format, ...);
    2325
    24 extern const char *getUserMessages();
     26extern std::string getUserMessages();
    2527
    2628extern void clearUserMessages();
  • 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.