Fix in dbExtractArray.c for DBF_STRING copies with wrap around
This commit is contained in:
committed by
Michael Davidsaver
parent
0e2a66e721
commit
ef4b2e5892
@@ -36,21 +36,21 @@ void dbExtractArrayFromRec(const dbAddr *paddr, void *pto,
|
||||
char isString = (paddr->field_type == DBF_STRING);
|
||||
|
||||
if (nRequest > no_elements) nRequest = no_elements;
|
||||
if (isString && dstSize >= MAX_STRING_SIZE) dstSize = MAX_STRING_SIZE - 1;
|
||||
if (isString && srcSize > MAX_STRING_SIZE) dstSize = MAX_STRING_SIZE;
|
||||
|
||||
if (increment == 1) {
|
||||
if (increment == 1 && dstSize == srcSize) {
|
||||
nUpperPart = nRequest < no_elements - offset ? nRequest : no_elements - offset;
|
||||
memcpy(pdst, &psrc[offset * srcSize], dstSize * nUpperPart);
|
||||
if (nRequest > nUpperPart)
|
||||
memcpy(&pdst[dstSize * nUpperPart], psrc, dstSize * (nRequest - nUpperPart));
|
||||
if (isString)
|
||||
for (i = 1; i <= nRequest; i++)
|
||||
pdst[dstSize*i] = '\0';
|
||||
pdst[dstSize*i-1] = '\0';
|
||||
} else {
|
||||
for (; nRequest > 0; nRequest--, pdst += srcSize, offset += increment) {
|
||||
for (; nRequest > 0; nRequest--, pdst += dstSize, offset += increment) {
|
||||
offset %= no_elements;
|
||||
memcpy(pdst, &psrc[offset*srcSize], dstSize);
|
||||
if (isString) pdst[dstSize] = '\0';
|
||||
if (isString) pdst[dstSize-1] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user