IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 25, 2006, 12:02:40 PM (20 years ago)
Author:
jhoblitt
Message:

bug #809 - use psStringAppendV() instead of calling vsnprintf() directly in p_psDBRunQuery() & p_psDBRunQueryPrepared(). This is to fix a) the segfaults on amd64 caused by unsafe repeated use of va_lists and b) eliminates code duplicated code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/db/psDB.c

    r8526 r8602  
    1212 *  @author Joshua Hoblitt
    1313 *
    14  *  @version $Revision: 1.85 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2006-08-23 23:23:13 $
     14 *  @version $Revision: 1.86 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2006-08-25 22:02:40 $
    1616 *
    1717 *  Copyright (C) 2005-2006  Joshua Hoblitt, University of Hawaii
     
    808808
    809809    // Run query
    810     va_list argPtr;
    811     va_start(argPtr, format);
    812     if(argPtr == NULL) {
    813         query = psStringCopy(format);
    814     } else {
    815         int destSize = vsnprintf(query, 0, format, argPtr);
    816         query = psAlloc(destSize+1);
    817         vsnprintf(query, destSize+1, format, argPtr);
    818     }
    819     va_end(argPtr);
     810    va_list ap;
     811    va_start(ap, format);
     812    psStringAppendV(&query, format, ap);
     813    va_end(ap);
    820814
    821815    psTrace("psLib.db", PS_LOG_INFO, "Executing SQL: %s", query);
     
    852846
    853847    // generate query string
    854     va_list argPtr;
    855     va_start(argPtr, format);
    856     if(argPtr == NULL) {
    857         query = psStringCopy(format);
    858     } else {
    859         int destSize = vsnprintf(query, 0, format, argPtr);
    860         query = psAlloc(destSize + 1);
    861         vsnprintf(query, destSize + 1, format, argPtr);
    862     }
    863     va_end(argPtr);
     848    va_list ap;
     849    va_start(ap, format);
     850    psStringAppendV(&query, format, ap);
     851    va_end(ap);
    864852
    865853    psTrace("psLib.db", PS_LOG_INFO, "Executing SQL: %s", query);
Note: See TracChangeset for help on using the changeset viewer.