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.

File:
1 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;
Note: See TracChangeset for help on using the changeset viewer.