Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
0f9bfa82
Unverified
Commit
0f9bfa82
authored
7 years ago
by
Jisi Liu
Committed by
GitHub
7 years ago
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4016 from jquesnelle/string-access-ub
fix undefined behavior in C++03
parents
27e877fd
f5b08627
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
io_win32.cc
src/google/protobuf/stubs/io_win32.cc
+5
-4
No files found.
src/google/protobuf/stubs/io_win32.cc
View file @
0f9bfa82
...
...
@@ -155,12 +155,13 @@ string normalize(string path) {
static
const
string
dot
(
"."
);
static
const
string
dotdot
(
".."
);
const
char
*
p
=
path
.
c_str
();
std
::
vector
<
string
>
segments
;
int
segment_start
=
-
1
;
// Find the path segments in `path` (separated by "/").
for
(
int
i
=
0
;;
++
i
)
{
if
(
!
is_separator
(
p
ath
[
i
])
&&
path
[
i
]
!=
'\0'
)
{
if
(
!
is_separator
(
p
[
i
])
&&
p
[
i
]
!=
'\0'
)
{
// The current character does not end a segment, so start one unless it's
// already started.
if
(
segment_start
<
0
)
{
...
...
@@ -169,7 +170,7 @@ string normalize(string path) {
}
else
if
(
segment_start
>=
0
&&
i
>
segment_start
)
{
// The current character is "/" or "\0", so this ends a segment.
// Add that to `segments` if there's anything to add; handle "." and "..".
string
segment
(
p
ath
,
segment_start
,
i
-
segment_start
);
string
segment
(
p
,
segment_start
,
i
-
segment_start
);
segment_start
=
-
1
;
if
(
segment
==
dotdot
)
{
if
(
!
segments
.
empty
()
&&
...
...
@@ -180,7 +181,7 @@ string normalize(string path) {
segments
.
push_back
(
segment
);
}
}
if
(
p
ath
[
i
]
==
'\0'
)
{
if
(
p
[
i
]
==
'\0'
)
{
break
;
}
}
...
...
@@ -203,7 +204,7 @@ string normalize(string path) {
result
<<
segments
[
i
];
}
// Preserve trailing separator if the input contained it.
if
(
!
path
.
empty
()
&&
is_separator
(
p
ath
[
path
.
size
()
-
1
]))
{
if
(
!
path
.
empty
()
&&
is_separator
(
p
[
path
.
size
()
-
1
]))
{
result
<<
'\\'
;
}
return
result
.
str
();
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment