Potential memory leak in hlindex_open when open_table_from_share fails
@JoeJRW がすでに取り組んでいます。
2026年5月18日 から。
評価
この issue はまだ評価されていません。
説明
In sql/vidx/vidx_index.cc, the hlindex_open function allocates memory for hlindex with my_malloc() at line 980, and increments s->hlindex->ref_count() at lines 988-990 before calling open_table_from_share().
However, when open_table_from_share() fails (error != 0), the function jumps to error_end at line 1001 without:
Decrementing the ref_count that was previously incremented
Freeing the allocated hlindex memory
Code location :
// Line 980: Allocate hlindex
hlindex = (TABLE *)my_malloc(key_memory_TABLE, sizeof(*hlindex), MYF(MY_WME));
// Lines 987-990: Increment ref_count
if (s->hlindex->tmp_table == NO_TMP_TABLE) {
mysql_mutex_lock(&LOCK_open);
s->hlindex->increment_ref_count();
mysql_mutex_unlock(&LOCK_open);
}
// Lines 993-997: Call open_table_from_share
int error = open_table_from_share(in_use, s->hlindex, hlindex_name,
(uint)(HA_OPEN_KEYFILE | HA_OPEN_RNDFILE |
HA_GET_INDEX | HA_TRY_READ_ONLY),
EXTRA_RECORD, in_use->open_options,
hlindex, false, hlindex_dd);
// Lines 999-1001: Problem: When error != 0, no cleanup before goto error_end
if (error != 0 || hlindex == nullptr) {
error_message = "Failed to open_table_from_share.";
goto error_end; // Memory leak here!
}
Note: open_table_from_share() does NOT free the passed outparam pointer on failure (verified in sql/table.cc). It only cleans internal resources.
Suggested fix:
if (error != 0 || hlindex == nullptr) {
error_message = "Failed to open_table_from_share.";
if (hlindex != nullptr) {
if (s->hlindex->tmp_table == NO_TMP_TABLE) {
mysql_mutex_lock(&LOCK_open);
s->hlindex->decrement_ref_count();
mysql_mutex_unlock(&LOCK_open);
}
my_free(hlindex);
hlindex = nullptr;
}
goto error_end;
}
- 主要言語
- C++
- スター
- 6k
- フォーク
- 902
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
alibaba/AliSQL のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
-
Deployment Architecture Issues再び着手できるかも @p1p1bear が 69 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
espressif/esp-matter#1867 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
cuAmpcorParameter.cpp (CPU pycuampcor) does not compile with libc++: EXIT_FAILURE is undeclaredオープン
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
isce-framework/isce3#387 ·
-
upstream update
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
conan-io/conan-center-index#31055 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信