[BuildDB-C-API] Fix buffer read overflow
[BuildDB-C-API] Fix buffer read overflow

This was found by running tests under ASAN.

apple/swift-llbuild,apple/swift-llbuild,apple/swift-llbuild,apple/swift-llbuild,apple/swift-llbuild,apple/swift-llbuild,apple/swift-llbuild