clang -cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -disable-free -main-file-name buffer.cc -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -momit-leaf-frame-pointer -ffunction-sections -fdata-sections -resource-dir /home/alan/workspace/canalyze/llvm/sprinter/build/bin/resources -isystem /home/alan/workspace/canalyze/llvm/sprinter/build/bin/resources/include -isystem /home/alan/workspace/canalyze/llvm/llvm-git/build/smtptr-test/testcase/mysql-server/extra/rapidjson/include -isystem /home/alan/workspace/canalyze/llvm/llvm-git/build/smtptr-test/testcase/mysql-server/extra/lz4 -isystem /home/alan/workspace/canalyze/llvm/llvm-git/build/smtptr-test/testcase/mysql-server/extra/libedit/libedit-20190324-3.1/src/editline -isystem /home/alan/workspace/canalyze/llvm/llvm-git/build/smtptr-test/testcase/mysql-server/extra/zstd/lib -isystem /home/alan/workspace/canalyze/llvm/llvm-git/build/smtptr-test/testcase/mysql-server/build/extra/zlib -isystem /home/alan/workspace/canalyze/llvm/llvm-git/build/smtptr-test/testcase/mysql-server/extra/zlib -I /home/alan/workspace/canalyze/llvm/sprinter/build/bin/resources/include -D HAVE_CONFIG_H -D HAVE_TLSv13 -D LOG_COMPONENT_TAG="keyring_file" -D LZ4_DISABLE_DEPRECATE_WARNINGS -D MYSQL_DYNAMIC_PLUGIN -D RAPIDJSON_NO_SIZETYPEDEFINE -D RAPIDJSON_SCHEMA_USE_INTERNALREGEX=0 -D RAPIDJSON_SCHEMA_USE_STDREGEX=1 -D _FILE_OFFSET_BITS=64 -D _GNU_SOURCE -D _USE_MATH_DEFINES -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -D keyring_file_EXPORTS -I /home/alan/workspace/canalyze/llvm/llvm-git/build/smtptr-test/testcase/mysql-server/build -I /home/alan/workspace/canalyze/llvm/llvm-git/build/smtptr-test/testcase/mysql-server/build/include -I /home/alan/workspace/canalyze/llvm/llvm-git/build/smtptr-test/testcase/mysql-server -I /home/alan/workspace/canalyze/llvm/llvm-git/build/smtptr-test/testcase/mysql-server/include -D DBUG_OFF -D NDEBUG -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/backward -internal-isystem /usr/local/include -internal-isystem /home/alan/workspace/canalyze/llvm/sprinter/build/bin/resources/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wall -Wextra -Wformat-security -Wvla -Wundef -Wmissing-format-attribute -Woverloaded-virtual -Wcast-qual -Wimplicit-fallthrough=2 -Wstringop-truncation -Wlogical-op -w -std=c++14 -fdeprecated-macro -fdebug-compilation-dir /home/alan/workspace/canalyze/llvm/llvm-git/build/smtptr-test/testcase/mysql-server/build/plugin/keyring -ferror-limit 19 -fmessage-length 0 -ftls-model=initial-exec -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -vectorize-loops -vectorize-slp -faddrsig -x c++ /home/alan/workspace/canalyze/llvm/llvm-git/build/smtptr-test/testcase/mysql-server/plugin/keyring/buffer.cc
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | #include "plugin/keyring/buffer.h" |
24 | |
25 | #include <memory> |
26 | |
27 | #include "my_dbug.h" |
28 | #include "plugin/keyring/common/keyring_key.h" |
29 | |
30 | namespace keyring { |
31 | void Buffer::free() { |
32 | if (data != nullptr) { |
33 | delete[] data; |
34 | data = nullptr; |
35 | } |
36 | mark_as_empty(); |
37 | DBUG_ASSERT(size == 0 && position == 0); |
38 | } |
39 | |
40 | bool Buffer::get_next_key(IKey **key) { |
41 | *key = nullptr; |
42 | |
43 | std::unique_ptr<Key> key_ptr(new Key()); |
| 1 | Calling 'Keyring_alloc::operator new' | |
|
| 7 | | Returning from 'Keyring_alloc::operator new' | |
|
| 8 | | Pointer assignment: class std::unique_ptr<struct keyring::Key, struct std::default_delete<struct keyring::Key> > key_ptr = nullptr | |
|
44 | size_t number_of_bytes_read_from_buffer = 0; |
45 | if (data == nullptr) { |
| 9 | | Assuming the condition is false | |
|
| |
46 | DBUG_ASSERT(size == 0); |
47 | return true; |
48 | } |
49 | if (key_ptr->load_from_buffer( |
| 11 | | Dereference an empty smart pointer by calling operator -> |
|
50 | data + position, &number_of_bytes_read_from_buffer, size - position)) |
51 | return true; |
52 | |
53 | position += number_of_bytes_read_from_buffer; |
54 | *key = key_ptr.release(); |
55 | return false; |
56 | } |
57 | |
58 | bool Buffer::has_next_key() { return position < size; } |
59 | |
60 | void Buffer::reserve(size_t memory_size) { |
61 | DBUG_ASSERT(memory_size % sizeof(size_t) == |
62 | 0); |
63 | free(); |
64 | data = reinterpret_cast<uchar *>( |
65 | new size_t[memory_size / sizeof(size_t)]); |
66 | size = memory_size; |
67 | if (data) memset(data, 0, size); |
68 | position = 0; |
69 | } |
70 | |
71 | } |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | #ifndef MYSQL_KEYRING_MEMORY_H |
24 | #define MYSQL_KEYRING_MEMORY_H |
25 | |
26 | #include <mysql/plugin_keyring.h> |
27 | #include <limits> |
28 | #include <memory> |
29 | |
30 | namespace keyring { |
31 | |
32 | extern PSI_memory_key key_memory_KEYRING; |
33 | |
34 | template <class T> |
35 | T keyring_malloc(size_t size) { |
36 | void *allocated_memory = my_malloc(key_memory_KEYRING, size, MYF(MY_WME)); |
| 3 | | Conservative call: mysql_malloc_service_st::mysql_malloc | |
|
37 | return allocated_memory ? reinterpret_cast<T>(allocated_memory) : NULL; |
| 4 | | Assuming 'allocated_memory' is null | |
|
| |
38 | } |
39 | |
40 | class Keyring_alloc { |
41 | public: |
42 | static void *operator new(size_t size) noexcept { |
43 | return keyring_malloc<void *>(size); |
| 2 | | Calling 'keyring_malloc<void *>' | |
|
| 6 | | Returning from 'keyring_malloc<void *>' | |
|
44 | } |
45 | static void *operator new[](size_t size) noexcept { |
46 | return keyring_malloc<void *>(size); |
47 | } |
48 | static void operator delete(void *ptr, std::size_t) { my_free(ptr); } |
49 | static void operator delete[](void *ptr, std::size_t) { my_free(ptr); } |
50 | }; |
51 | } |
52 | |
53 | #endif // MYSQL_KEYRING_MEMORY_H |