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

Legend:

Unmodified
Added
Removed
  • 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();
Note: See TracChangeset for help on using the changeset viewer.