Skip to content

Commit

Permalink
Merge pull request taosdata#209 from taosdata/fix/xftan/largestring-main
Browse files Browse the repository at this point in the history
fix: parse large string length with uint16
  • Loading branch information
huskar-t authored Nov 8, 2023
2 parents 22bd599 + c6c40a5 commit 789b107
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions common/parser/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@ func rawConvertBinary(pHeader, pStart unsafe.Pointer, row int) driver.Value {
return nil
}
currentRow := pointer.AddUintptr(pStart, uintptr(offset))
clen := *((*int16)(currentRow))
clen := *((*uint16)(currentRow))
currentRow = unsafe.Pointer(uintptr(currentRow) + 2)

binaryVal := make([]byte, clen)

for index := int16(0); index < clen; index++ {
for index := uint16(0); index < clen; index++ {
binaryVal[index] = *((*byte)(unsafe.Pointer(uintptr(currentRow) + uintptr(index))))
}
return string(binaryVal[:])
Expand All @@ -217,12 +217,12 @@ func rawConvertNchar(pHeader, pStart unsafe.Pointer, row int) driver.Value {
return nil
}
currentRow := pointer.AddUintptr(pStart, uintptr(offset))
clen := *((*int16)(currentRow)) / 4
clen := *((*uint16)(currentRow)) / 4
currentRow = unsafe.Pointer(uintptr(currentRow) + 2)

binaryVal := make([]rune, clen)

for index := int16(0); index < clen; index++ {
for index := uint16(0); index < clen; index++ {
binaryVal[index] = *((*rune)(unsafe.Pointer(uintptr(currentRow) + uintptr(index*4))))
}
return string(binaryVal)
Expand All @@ -234,12 +234,12 @@ func rawConvertJson(pHeader, pStart unsafe.Pointer, row int) driver.Value {
return nil
}
currentRow := pointer.AddUintptr(pStart, uintptr(offset))
clen := *((*int16)(currentRow))
clen := *((*uint16)(currentRow))
currentRow = pointer.AddUintptr(currentRow, 2)

binaryVal := make([]byte, clen)

for index := int16(0); index < clen; index++ {
for index := uint16(0); index < clen; index++ {
binaryVal[index] = *((*byte)(pointer.AddUintptr(currentRow, uintptr(index))))
}
return binaryVal[:]
Expand Down

0 comments on commit 789b107

Please sign in to comment.