Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
HAWQ-1774. fix potential issue in DecimalVector::append
Browse files Browse the repository at this point in the history
  • Loading branch information
Librago committed Nov 24, 2020
1 parent 4958d4d commit 5843970
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions depends/dbcommon/src/dbcommon/common/vector/decimal-vector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,12 @@ void DecimalVector::append(const char *v, uint64_t valueLen, bool null) {
}

void DecimalVector::append(const Datum &datum, bool null) {
dbcommon::DecimalVar *val = DatumGetValue<DecimalVar *>(datum);
if (val) {
if (!null) {
dbcommon::DecimalVar *val = DatumGetValue<DecimalVar *>(datum);
values.append(val->lowbits);
auxiliaryValues.append(val->highbits);
scaleValues.append(val->scale);
} else {
assert(null == true);
values.append(uint64_t(0));
auxiliaryValues.append(int64_t(0));
scaleValues.append(int64_t(0));
Expand All @@ -108,11 +107,15 @@ void DecimalVector::append(const Datum &datum, bool null) {
}

void DecimalVector::append(const Scalar *scalar) {
dbcommon::DecimalVar *val = DatumGetValue<DecimalVar *>(scalar->value);
if (val) {
if (!scalar->isnull) {
dbcommon::DecimalVar *val = DatumGetValue<DecimalVar *>(scalar->value);
values.append(val->lowbits);
auxiliaryValues.append(val->highbits);
scaleValues.append(val->scale);
} else {
values.append(uint64_t(0));
auxiliaryValues.append(int64_t(0));
scaleValues.append(int64_t(0));
}
appendNull(scalar->isnull);
}
Expand Down

0 comments on commit 5843970

Please sign in to comment.