Skip to content

Commit 3f27e12

Browse files
author
Halliday, Gavin (RIS-HBE)
authored
Merge pull request #36533 from risk-hsy/campda01_risk/36529-rtlfield-length
fix(rtl): handle UNKNOWN_LENGTH1/2 in length-size byte calculation Reviewed-by: Gavin Halliday <gavin.halliday@lexisnexisrisk.com> Merged-by: Gavin Halliday <gavin.halliday@lexisnexisrisk.com>
2 parents 7677218 + 67d6ae9 commit 3f27e12

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

rtl/eclrtl/rtlfield.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,11 +393,14 @@ unsigned RtlTypeInfoBase::getLengthSizeBytes() const
393393
switch (length)
394394
{
395395
case 1:
396+
case UNKNOWN_LENGTH1:
397+
return 1;
396398
case 2:
397-
return length;
399+
case UNKNOWN_LENGTH2:
400+
return 2;
398401
}
399-
dbgassertex(length == 0 || length == UNKNOWN_LENGTH);
400-
//case 0, UNKNOWN_LENGTH - no
402+
// Some generated metadata uses non-1/2 markers for variable-length payloads.
403+
// Any value not explicitly handled above maps to a 4-byte length prefix.
401404
return 4;
402405
}
403406

@@ -408,8 +411,10 @@ size32_t RtlTypeInfoBase::getUnknownLengthMax() const
408411
switch (length)
409412
{
410413
case 1:
414+
case UNKNOWN_LENGTH1:
411415
return 0xFF;
412416
case 2:
417+
case UNKNOWN_LENGTH2:
413418
return 0xFFFF;
414419
}
415420
}
@@ -421,9 +426,11 @@ void RtlTypeInfoBase::writeSize(void * dest, size32_t size) const
421426
switch (length)
422427
{
423428
case 1:
429+
case UNKNOWN_LENGTH1:
424430
rtlWriteInt1(dest, size);
425431
break;
426432
case 2:
433+
case UNKNOWN_LENGTH2:
427434
rtlWriteInt2(dest, size);
428435
break;
429436
default:
@@ -439,9 +446,11 @@ size32_t RtlTypeInfoBase::readAheadSize(IRowPrefetcherSource & in) const
439446
switch (length)
440447
{
441448
case 1:
449+
case UNKNOWN_LENGTH1:
442450
in.read(1, temp);
443451
return rtlReadInt1(temp);
444452
case 2:
453+
case UNKNOWN_LENGTH2:
445454
in.read(2, temp);
446455
return rtlReadInt2(temp);
447456
default:
@@ -454,8 +463,10 @@ size32_t RtlTypeInfoBase::readSize(const void * src) const
454463
switch (length)
455464
{
456465
case 1:
466+
case UNKNOWN_LENGTH1:
457467
return rtlReadInt1(src);
458468
case 2:
469+
case UNKNOWN_LENGTH2:
459470
return rtlReadInt2(src);
460471
default:
461472
return rtlReadInt4(src);
@@ -1250,8 +1261,10 @@ size32_t RtlStringTypeInfo::size(const byte * self, const byte * selfrow) const
12501261
switch (length)
12511262
{
12521263
case 1:
1264+
case UNKNOWN_LENGTH1:
12531265
return 1 + rtlReadInt1(self);
12541266
case 2:
1267+
case UNKNOWN_LENGTH2:
12551268
return 2 + rtlReadInt2(self);
12561269
default:
12571270
return 4 + rtlReadSize32t(self);

0 commit comments

Comments
 (0)