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
c44c3af2
Commit
c44c3af2
authored
Aug 23, 2017
by
Jisi Liu
Committed by
GitHub
Aug 23, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3548 from google/3.4.x
Merge fixes from 3.4.x into master
parents
7a431378
30681c75
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
42 additions
and
55 deletions
+42
-55
GPBUtil.php
php/src/Google/Protobuf/Internal/GPBUtil.php
+1
-1
Message.php
php/src/Google/Protobuf/Internal/Message.php
+3
-0
generated_class_test.php
php/tests/generated_class_test.php
+12
-0
memory_leak_test.php
php/tests/memory_leak_test.php
+2
-0
test.proto
php/tests/proto/test.proto
+7
-0
message_unittest.cc
src/google/protobuf/message_unittest.cc
+0
-38
io_win32.cc
src/google/protobuf/stubs/io_win32.cc
+15
-15
googletest.h
src/google/protobuf/testing/googletest.h
+2
-1
No files found.
php/src/Google/Protobuf/Internal/GPBUtil.php
View file @
c44c3af2
...
...
@@ -270,7 +270,7 @@ class GPBUtil
$name
,
$file_proto
)
{
$classname
=
implode
(
'_'
,
array_map
(
'ucwords'
,
explode
(
'.'
,
$name
)
));
$classname
=
implode
(
'_'
,
explode
(
'.'
,
$name
));
return
static
::
getClassNamePrefix
(
$classname
,
$file_proto
)
.
$classname
;
}
...
...
php/src/Google/Protobuf/Internal/Message.php
View file @
c44c3af2
...
...
@@ -76,6 +76,9 @@ class Message
}
$pool
=
DescriptorPool
::
getGeneratedPool
();
$this
->
desc
=
$pool
->
getDescriptorByClassName
(
get_class
(
$this
));
if
(
is_null
(
$this
->
desc
))
{
user_error
(
get_class
(
$this
)
.
"is not found in descriptor pool."
);
}
foreach
(
$this
->
desc
->
getField
()
as
$field
)
{
$setter
=
$field
->
getSetter
();
if
(
$field
->
isMap
())
{
...
...
php/tests/generated_class_test.php
View file @
c44c3af2
...
...
@@ -14,6 +14,8 @@ use Foo\TestIncludePrefixMessage;
use
Foo\TestMessage
;
use
Foo\TestMessage_Sub
;
use
Foo\TestReverseFieldOrder
;
use
Foo\testLowerCaseMessage
;
use
Foo\testLowerCaseEnum
;
use
Php\Test\TestNamespace
;
class
GeneratedClassTest
extends
TestBase
...
...
@@ -715,4 +717,14 @@ class GeneratedClassTest extends TestBase
$this
->
assertSame
(
"abc"
,
$m
->
getB
());
$this
->
assertNotSame
(
"abc"
,
$m
->
getA
());
}
#########################################################
# Test Reverse Field Order.
#########################################################
public
function
testLowerCase
()
{
$m
=
new
testLowerCaseMessage
();
$n
=
testLowerCaseEnum
::
VALUE
;
}
}
php/tests/memory_leak_test.php
View file @
c44c3af2
...
...
@@ -23,6 +23,8 @@ require_once('generated/Foo/TestPhpDoc.php');
require_once
(
'generated/Foo/TestRandomFieldOrder.php'
);
require_once
(
'generated/Foo/TestReverseFieldOrder.php'
);
require_once
(
'generated/Foo/TestUnpackedMessage.php'
);
require_once
(
'generated/Foo/testLowerCaseMessage.php'
);
require_once
(
'generated/Foo/testLowerCaseEnum.php'
);
require_once
(
'generated/GPBMetadata/Proto/Test.php'
);
require_once
(
'generated/GPBMetadata/Proto/TestEmptyPhpNamespace.php'
);
require_once
(
'generated/GPBMetadata/Proto/TestInclude.php'
);
...
...
php/tests/proto/test.proto
View file @
c44c3af2
...
...
@@ -192,3 +192,10 @@ message TestReverseFieldOrder {
repeated
int32
a
=
2
;
string
b
=
1
;
}
message
testLowerCaseMessage
{
}
enum
testLowerCaseEnum
{
VALUE
=
0
;
}
src/google/protobuf/message_unittest.cc
View file @
c44c3af2
...
...
@@ -257,44 +257,6 @@ TEST(MessageTest, CheckInitialized) {
"fields: a, b, c"
);
}
TEST
(
MessageTest
,
CheckOverflow
)
{
unittest
::
TestAllTypes
message
;
// Create a message with size just over 2GB. This triggers integer overflow
// when computing message size.
const
string
data
(
1024
,
'x'
);
Cord
one_megabyte
;
for
(
int
i
=
0
;
i
<
1024
;
i
++
)
{
one_megabyte
.
Append
(
data
);
}
for
(
int
i
=
0
;
i
<
2
*
1024
+
1
;
++
i
)
{
message
.
add_repeated_cord
()
->
CopyFrom
(
one_megabyte
);
}
Cord
serialized
;
EXPECT_FALSE
(
message
.
AppendToCord
(
&
serialized
));
}
TEST
(
MessageTest
,
CheckBigOverflow
)
{
// Checking for 4GB buffers on 32 bit systems is problematic.
if
(
sizeof
(
void
*
)
<
8
)
return
;
unittest
::
TestAllTypes
message
;
// Create a message with size just over 4GB. We should be able to detect this
// too, even though it will make a plain "int" wrap back to a positive number.
const
string
data
(
1024
,
'x'
);
Cord
one_megabyte
;
for
(
int
i
=
0
;
i
<
1024
;
i
++
)
{
one_megabyte
.
Append
(
data
);
}
for
(
int
i
=
0
;
i
<
4
*
1024
+
1
;
++
i
)
{
message
.
add_repeated_cord
()
->
CopyFrom
(
one_megabyte
);
}
Cord
serialized
;
EXPECT_FALSE
(
message
.
AppendToCord
(
&
serialized
));
}
#endif // PROTOBUF_HAS_DEATH_TEST
namespace
{
...
...
src/google/protobuf/stubs/io_win32.cc
View file @
c44c3af2
...
...
@@ -57,6 +57,7 @@
#include <windows.h>
#include <google/protobuf/stubs/io_win32.h>
#include <google/protobuf/stubs/scoped_ptr.h>
#include <cassert>
#include <memory>
...
...
@@ -71,7 +72,6 @@ namespace win32 {
namespace
{
using
std
::
string
;
using
std
::
unique_ptr
;
using
std
::
wstring
;
template
<
typename
char_type
>
...
...
@@ -139,11 +139,11 @@ string join_paths(const string& path1, const string& path2) {
return
path1
;
}
if
(
is_separator
(
path1
.
back
()
))
{
return
is_separator
(
path2
.
front
()
)
?
(
path1
+
path2
.
substr
(
1
))
if
(
is_separator
(
path1
[
path1
.
size
()
-
1
]
))
{
return
is_separator
(
path2
[
0
]
)
?
(
path1
+
path2
.
substr
(
1
))
:
(
path1
+
path2
);
}
else
{
return
is_separator
(
path2
.
front
()
)
?
(
path1
+
path2
)
return
is_separator
(
path2
[
0
]
)
?
(
path1
+
path2
)
:
(
path1
+
'\\'
+
path2
);
}
}
...
...
@@ -203,24 +203,24 @@ string normalize(string path) {
result
<<
s
;
}
// Preserve trailing separator if the input contained it.
if
(
is_separator
(
path
.
back
()
))
{
if
(
!
path
.
empty
()
&&
is_separator
(
path
[
path
.
size
()
-
1
]
))
{
result
<<
'\\'
;
}
return
result
.
str
();
}
std
::
unique_ptr
<
WCHAR
[]
>
as_wstring
(
const
string
&
s
)
{
WCHAR
*
as_wstring
(
const
string
&
s
)
{
int
len
=
::
MultiByteToWideChar
(
CP_UTF8
,
0
,
s
.
c_str
(),
s
.
size
(),
NULL
,
0
);
std
::
unique_ptr
<
WCHAR
[]
>
result
(
new
WCHAR
[
len
+
1
])
;
::
MultiByteToWideChar
(
CP_UTF8
,
0
,
s
.
c_str
(),
s
.
size
(),
result
.
get
()
,
len
+
1
);
result
.
get
()
[
len
]
=
0
;
return
std
::
move
(
result
)
;
WCHAR
*
result
=
new
WCHAR
[
len
+
1
]
;
::
MultiByteToWideChar
(
CP_UTF8
,
0
,
s
.
c_str
(),
s
.
size
(),
result
,
len
+
1
);
result
[
len
]
=
0
;
return
result
;
}
wstring
as_wchar_path
(
const
string
&
path
)
{
s
td
::
unique_ptr
<
WCHAR
[]
>
wbuf
(
as_wstring
(
path
));
void
as_wchar_path
(
const
string
&
path
,
wstring
*
wchar_
path
)
{
s
coped_array
<
WCHAR
>
wbuf
(
as_wstring
(
path
));
replace_directory_separators
(
wbuf
.
get
());
return
wstring
(
wbuf
.
get
());
wchar_path
->
assign
(
wbuf
.
get
());
}
bool
as_windows_path
(
const
string
&
path
,
wstring
*
result
)
{
...
...
@@ -239,7 +239,7 @@ bool as_windows_path(const string& path, wstring* result) {
::
GetCurrentDirectoryA
(
MAX_PATH
,
cwd
);
mutable_path
=
join_paths
(
cwd
,
mutable_path
);
}
*
result
=
as_wchar_path
(
normalize
(
mutable_path
)
);
as_wchar_path
(
normalize
(
mutable_path
),
result
);
if
(
!
has_longpath_prefix
(
result
->
c_str
()))
{
// Add the "\\?\" prefix unconditionally. This way we prevent the Win32 API
// from processing the path and "helpfully" removing trailing dots from the
...
...
@@ -324,7 +324,7 @@ FILE* fopen(const char* path, const char* mode) {
errno
=
ENOENT
;
return
NULL
;
}
s
td
::
unique_ptr
<
WCHAR
[]
>
wmode
(
as_wstring
(
mode
));
s
coped_array
<
WCHAR
>
wmode
(
as_wstring
(
mode
));
return
::
_wfopen
(
wpath
.
c_str
(),
wmode
.
get
());
#else
return
::
fopen
(
path
,
mode
);
...
...
src/google/protobuf/testing/googletest.h
View file @
c44c3af2
...
...
@@ -39,7 +39,8 @@
#include <google/protobuf/stubs/common.h>
#include <gmock/gmock.h>
// Disable death tests if we use exceptions in CHECK().
#if !PROTOBUF_USE_EXCEPTIONS && defined(GTEST_HAS_DEATH_TEST)
#if !PROTOBUF_USE_EXCEPTIONS && defined(GTEST_HAS_DEATH_TEST) && \
!GTEST_OS_WINDOWS
#define PROTOBUF_HAS_DEATH_TEST
#endif
...
...
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