Fix memory leak with fetchAsString/fetchAsBuffer
This commit is contained in:
parent
bfc26f00bb
commit
da1af500a5
|
@ -483,6 +483,16 @@ typedef struct eBaton
|
|||
}
|
||||
}
|
||||
|
||||
// If Blob data was fetched as Buffer, deallocate each buffer
|
||||
if ( (defines[i].fetchType == dpi::DpiRaw) &&
|
||||
mInfo[i].dbType == dpi::DpiBlob )
|
||||
{
|
||||
for ( unsigned int j = 0 ; j < maxRows ; j ++ )
|
||||
{
|
||||
free ( ((char **)(defines[i].buf))[j] );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Buf and indicator will be allocated in all cases.
|
||||
* len will NOT be allocated for CLOB-as-STRING/BLOB-as-BUFFER
|
||||
|
|
|
@ -711,6 +711,7 @@ void ResultSet::clearFetchBuffer( unsigned int numRows )
|
|||
{
|
||||
if ( defineBuffers_[i].dttmarr )
|
||||
{
|
||||
/* Date/Timestamp columns */
|
||||
defineBuffers_[i].dttmarr->release ();
|
||||
defineBuffers_[i].extbuf = NULL;
|
||||
}
|
||||
|
@ -718,6 +719,7 @@ void ResultSet::clearFetchBuffer( unsigned int numRows )
|
|||
( defineBuffers_[i].fetchType == DpiBlob ) ||
|
||||
( defineBuffers_[i].fetchType == DpiBfile ) )
|
||||
{
|
||||
/* Lob columns */
|
||||
for (unsigned int j = 0; j < numRows; j++)
|
||||
{
|
||||
if (((Descriptor **)(defineBuffers_[i].buf))[j])
|
||||
|
@ -727,6 +729,21 @@ void ResultSet::clearFetchBuffer( unsigned int numRows )
|
|||
}
|
||||
}
|
||||
}
|
||||
else if ( ( ( defineBuffers_[i].fetchType == dpi::DpiVarChar ) &&
|
||||
( mInfo_[i].dbType == dpi::DpiClob ) ) ||
|
||||
( ( defineBuffers_[i].fetchType == dpi::DpiRaw ) &&
|
||||
( mInfo_[i].dbType == dpi::DpiBlob ) ) )
|
||||
{
|
||||
/* CLOB-as-STRING or BLOB-as-BUFFER case */
|
||||
for ( unsigned int j = 0 ; j < numRows ; j ++ )
|
||||
{
|
||||
if ( ( (char **)defineBuffers_[i].buf)[j] )
|
||||
{
|
||||
free ( ( (char **)defineBuffers_[i].buf)[j] );
|
||||
( ( char **)defineBuffers_[i].buf)[j] = NULL ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(defineBuffers_[i].buf);
|
||||
free(defineBuffers_[i].len);
|
||||
|
|
Loading…
Reference in New Issue