Skip to content

Commit de3a153

Browse files
author
Ole John Aske
committed
Bug #27461752 NDB-API, INDEXSCANOPERATION, INCORRECT RESULT WHEN NULL-BOUND IS SPECIFIED
Code generated for NdbIndexScanOperation::setBoundHelperOldApi() failed to set the 'nullBit' mask correctly if a NULL value was specified for the 'bound'. Was caused by 'delete-null-pointer-checks' optimization in gcc compiler, in combination with memcpy() having the 'nonnull' property set for its two pointer arguments. Thus it assumed that 'aValue != NULL' and eliminated later code checking for 'aValue == NULL' (cherry picked from commit e0a930454239e447e44c0ed9b0294e6ac3e05f75)
1 parent 0a35a78 commit de3a153

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

storage/ndb/src/ndbapi/NdbScanOperation.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -3135,18 +3135,23 @@ NdbIndexScanOperation::setBoundHelperOldApi(OldApiBoundInfo& boundInfo,
31353135
}
31363136
}
31373137

3138-
/* Copy data into correct part of RecAttr */
3139-
assert(byteOffset + valueLen <= maxKeyRecordBytes);
3140-
3141-
memcpy(boundInfo.key + byteOffset,
3142-
aValue,
3143-
valueLen);
3144-
3145-
/* Set Null bit */
3146-
bool nullBit=(aValue == NULL);
3138+
if (aValue != NULL)
3139+
{
3140+
/* Copy data into correct part of RecAttr */
3141+
assert(valueLen > 0);
3142+
assert(byteOffset + valueLen <= maxKeyRecordBytes);
31473143

3148-
boundInfo.key[nullbit_byte_offset]|=
3149-
(nullBit) << nullbit_bit_in_byte;
3144+
memcpy(boundInfo.key + byteOffset,
3145+
aValue,
3146+
valueLen);
3147+
}
3148+
else
3149+
{
3150+
/* Set Null bit */
3151+
assert(valueLen == 0);
3152+
boundInfo.key[nullbit_byte_offset] |=
3153+
(1 << nullbit_bit_in_byte);
3154+
}
31503155

31513156
return 0;
31523157
}

0 commit comments

Comments
 (0)