Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8ea7d79

Browse filesBrowse files
codebyteretargos
authored andcommitted
src: avoid shadowed string in fs_permission
PR-URL: #51123 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent 22a11c3 commit 8ea7d79
Copy full SHA for 8ea7d79

File tree

Expand file treeCollapse file tree

1 file changed

+10
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-8
lines changed
Open diff view settings
Collapse file

‎src/permission/fs_permission.h‎

Copy file name to clipboardExpand all lines: src/permission/fs_permission.h
+10-8Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,26 @@ class FSPermission final : public PermissionBase {
3333

3434
Node() : wildcard_child(nullptr), is_leaf(false) {}
3535

36-
Node* CreateChild(const std::string& prefix) {
37-
if (prefix.empty() && !is_leaf) {
36+
Node* CreateChild(const std::string& path_prefix) {
37+
if (path_prefix.empty() && !is_leaf) {
3838
is_leaf = true;
3939
return this;
4040
}
41-
char label = prefix[0];
41+
42+
CHECK(!path_prefix.empty());
43+
char label = path_prefix[0];
4244

4345
Node* child = children[label];
4446
if (child == nullptr) {
45-
children[label] = new Node(prefix);
47+
children[label] = new Node(path_prefix);
4648
return children[label];
4749
}
4850

4951
// swap prefix
5052
size_t i = 0;
51-
size_t prefix_len = prefix.length();
53+
size_t prefix_len = path_prefix.length();
5254
for (; i < child->prefix.length(); ++i) {
53-
if (i > prefix_len || prefix[i] != child->prefix[i]) {
55+
if (i > prefix_len || path_prefix[i] != child->prefix[i]) {
5456
std::string parent_prefix = child->prefix.substr(0, i);
5557
std::string child_prefix = child->prefix.substr(i);
5658

@@ -59,11 +61,11 @@ class FSPermission final : public PermissionBase {
5961
split_child->children[child_prefix[0]] = child;
6062
children[parent_prefix[0]] = split_child;
6163

62-
return split_child->CreateChild(prefix.substr(i));
64+
return split_child->CreateChild(path_prefix.substr(i));
6365
}
6466
}
6567
child->is_leaf = true;
66-
return child->CreateChild(prefix.substr(i));
68+
return child->CreateChild(path_prefix.substr(i));
6769
}
6870

6971
Node* CreateWildcardChild() {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.