Skip to content

Backport to 3.0 - CORE-6509 and add missing NULL checks on bcb_bdb - #9293

Open
gabrieleciech wants to merge 1 commit into
FirebirdSQL:B3_0_Releasefrom
gabrieleciech:fix/cch-null-bdb-3.0
Open

gabrieleciech wants to merge 1 commit into
FirebirdSQL:B3_0_Releasefrom
gabrieleciech:fix/cch-null-bdb-3.0

Conversation

@gabrieleciech

Copy link
Copy Markdown
Contributor

Refs #9289 (3.0 part; the 4.0 part is a separate PR). NULL checks only, as suggested there.

expand_buffers() sets bcb_count before allocating the new BufferDescs, so after a BadAlloc the tail of bcb_rpt has no descriptor. In 3.0 that tail is not even initialised.

Change

  • expand_buffers(): initialise the new tail to NULL (as in CORE-6509, e17dfa6).
  • Stop at the first NULL bcb_bdb in every loop up to bcb_count that dereferences it: flushAll() (as in CORE-6509), CCH_down_grade_dbb(), CCH_flush_ast(), CCH_shutdown() (the catch path) and get_prec_walk_mark().

break is enough because descriptors are allocated in order, so the uninitialised entries are always a contiguous tail.

CCH_shutdown() was not listed in #9289: it has the same pattern in the cleanup after a failed CCH_flush().

Test

Compiled on Ubuntu 18.04, gcc 7.5 (src/jrd/cch.cpp, Release flags + -Wall). No automated test: reproducing it needs an allocation failure inside expand_buffers().

…CORE-6509)

expand_buffers() sets bcb_count before the new buffer descriptors are
allocated, so after a BadAlloc the tail of bcb_rpt has no BufferDesc.
Initialise the new tail to NULL (as CORE-6509 did in 4.0) and stop at the
first NULL in every loop over bcb_count that dereferences bcb_bdb:
flushAll(), CCH_down_grade_dbb(), CCH_flush_ast(), CCH_shutdown() and
get_prec_walk_mark().

Refs FirebirdSQL#9289
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants