Changeset 7819


Ignore:
Timestamp:
11/24/11 16:14:37 (8 years ago)
Author:
mario
Message:

sanity-check some buffer sizes, and use a bit faster readInt() method

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/legacy/jvmlink/src/main/c++/JVMLinkClient.cpp

    r7818 r7819  
    294294void JVMLinkClient::setVar(const std::string& argname, int* obj, int length) { 
    295295        debug("setVar: " << argname << " (int array)"); 
     296        if (length < 1) return; 
    296297        JVMLinkObject jvmObj(argname, INT_TYPE, length, obj); 
    297298        setVar(jvmObj); 
     
    306307void JVMLinkClient::setVar(const std::string& argname, std::string* obj, int length) { 
    307308        debug("setVar: " << argname << " (string array)"); 
     309        if (length < 1) return; 
    308310        JVMLinkObject jvmObj(argname, STRING_TYPE, length, obj); 
    309311        setVar(jvmObj); 
     
    318320void JVMLinkClient::setVar(const std::string& argname, char* obj, int length) { 
    319321        debug("setVar: " << argname << " (char array)"); 
     322        if (length < 1) return; 
    320323        JVMLinkObject jvmObj(argname, CHAR_TYPE, length, obj); 
    321324        setVar(jvmObj); 
     
    330333void JVMLinkClient::setVar(const std::string& argname, Byte* obj, int length) { 
    331334        debug("setVar: " << argname << " (byte array)"); 
     335        if (length < 1) return; 
    332336        JVMLinkObject jvmObj(argname, BYTE_TYPE, length, obj); 
    333337        setVar(jvmObj); 
     
    342346void JVMLinkClient::setVar(const std::string& argname, float* obj, int length) { 
    343347        debug("setVar: " << argname << " (float array)"); 
     348        if (length < 1) return; 
    344349        JVMLinkObject jvmObj(argname, FLOAT_TYPE, length, obj); 
    345350        setVar(jvmObj); 
     
    354359void JVMLinkClient::setVar(const std::string& argname, bool* obj, int length) { 
    355360        debug("setVar: " << argname << " (bool array)"); 
     361        if (length < 1) return; 
    356362        JVMLinkObject jvmObj(argname, BOOL_TYPE, length, obj); 
    357363        setVar(jvmObj); 
     
    366372void JVMLinkClient::setVar(const std::string& argname, double* obj, int length) { 
    367373        debug("setVar: " << argname << " (double array)"); 
     374        if (length < 1) return; 
    368375        JVMLinkObject jvmObj(argname, DOUBLE_TYPE, length, obj); 
    369376        setVar(jvmObj); 
     
    378385void JVMLinkClient::setVar(const std::string& argname, long long* obj, int length) { 
    379386        debug("setVar: " << argname << " (long array)"); 
     387        if (length < 1) return; 
    380388        JVMLinkObject jvmObj(argname, LONG_TYPE, length, obj); 
    381389        setVar(jvmObj); 
     
    390398void JVMLinkClient::setVar(const std::string& argname, short* obj, int length) { 
    391399        debug("setVar: " << argname << " (short array)"); 
     400        if (length < 1) return; 
    392401        JVMLinkObject jvmObj(argname, SHORT_TYPE, length, obj); 
    393402        setVar(jvmObj); 
     
    423432 
    424433int JVMLinkClient::readInt() { 
    425         return *(int*) readMessage(4); 
     434        int buf; 
     435        recv(conn, (char*)&buf, 4, 0); 
     436        return buf; 
    426437} 
    427438 
Note: See TracChangeset for help on using the changeset viewer.