Skip to content

Commit bca0baa

Browse files
authored
Merge pull request #8594 from FirebirdSQL/work/gh_8590_2
Fixed string_filter (used with internal blob types) that could not report isc_segment.
2 parents e4a112f + c867f34 commit bca0baa

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/jrd/filters.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,6 @@ static ISC_STATUS string_filter(USHORT action, BlobControl* control)
13261326
*
13271327
**************************************/
13281328
filter_tmp* string;
1329-
USHORT length;
13301329

13311330
switch (action)
13321331
{
@@ -1339,10 +1338,14 @@ static ISC_STATUS string_filter(USHORT action, BlobControl* control)
13391338
return FB_SUCCESS;
13401339

13411340
case isc_blob_filter_get_segment:
1341+
{
13421342
if (!(string = (filter_tmp*) control->ctl_data[1]))
13431343
return isc_segstr_eof;
1344-
length = string->tmp_length - control->ctl_data[2];
1345-
if (length > control->ctl_buffer_length)
1344+
1345+
USHORT length = string->tmp_length - control->ctl_data[2];
1346+
const bool outOfBuffer = (length > control->ctl_buffer_length);
1347+
1348+
if (outOfBuffer)
13461349
length = control->ctl_buffer_length;
13471350
memcpy(control->ctl_buffer, string->tmp_string + (USHORT) control->ctl_data[2], length);
13481351
control->ctl_data[2] += length;
@@ -1351,7 +1354,8 @@ static ISC_STATUS string_filter(USHORT action, BlobControl* control)
13511354
control->ctl_data[2] = 0;
13521355
}
13531356
control->ctl_segment_length = length;
1354-
return (length <= control->ctl_buffer_length) ? FB_SUCCESS : isc_segment;
1357+
return (!outOfBuffer) ? FB_SUCCESS : isc_segment;
1358+
}
13551359

13561360
case isc_blob_filter_put_segment:
13571361
case isc_blob_filter_create:

0 commit comments

Comments
 (0)