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
75b69887
Commit
75b69887
authored
Oct 05, 2016
by
Bo Yang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix segmentation fault when ZTS is defined.
parent
52ab3b07
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
34 deletions
+39
-34
array.c
php/ext/google/protobuf/array.c
+1
-2
encode_decode.c
php/ext/google/protobuf/encode_decode.c
+17
-11
type_check.c
php/ext/google/protobuf/type_check.c
+0
-1
array_test.php
php/tests/array_test.php
+20
-20
tests.sh
tests.sh
+1
-0
No files found.
php/ext/google/protobuf/array.c
View file @
75b69887
...
...
@@ -160,8 +160,7 @@ static void repeated_field_write_dimension(zval *object, zval *offset,
unsigned
char
memory
[
NATIVE_SLOT_MAX_SIZE
];
memset
(
memory
,
0
,
NATIVE_SLOT_MAX_SIZE
);
if
(
!
native_slot_set
(
intern
->
type
,
intern
->
msg_ce
,
memory
,
value
TSRMLS_CC
))
{
if
(
!
native_slot_set
(
intern
->
type
,
intern
->
msg_ce
,
memory
,
value
TSRMLS_CC
))
{
return
;
}
...
...
php/ext/google/protobuf/encode_decode.c
View file @
75b69887
...
...
@@ -199,8 +199,9 @@ static void *startseq_handler(void* closure, const void* hd) {
// Handlers that append primitive values to a repeated field.
#define DEFINE_APPEND_HANDLER(type, ctype) \
static bool append##type##_handler(void* closure, const void* hd, \
ctype val
TSRMLS_DC) {
\
ctype val
) {
\
zval* array = (zval*)closure; \
TSRMLS_FETCH(); \
RepeatedField* intern = \
(RepeatedField*)zend_object_store_get_object(array TSRMLS_CC); \
repeated_field_push_native(intern, &val TSRMLS_CC); \
...
...
@@ -218,8 +219,9 @@ DEFINE_APPEND_HANDLER(double, double)
// Appends a string to a repeated field.
static
void
*
appendstr_handler
(
void
*
closure
,
const
void
*
hd
,
size_t
size_hint
TSRMLS_DC
)
{
size_t
size_hint
)
{
zval
*
array
=
(
zval
*
)
closure
;
TSRMLS_FETCH
();
RepeatedField
*
intern
=
(
RepeatedField
*
)
zend_object_store_get_object
(
array
TSRMLS_CC
);
...
...
@@ -234,8 +236,9 @@ static void* appendstr_handler(void *closure,
// Appends a 'bytes' string to a repeated field.
static
void
*
appendbytes_handler
(
void
*
closure
,
const
void
*
hd
,
size_t
size_hint
TSRMLS_DC
)
{
size_t
size_hint
)
{
zval
*
array
=
(
zval
*
)
closure
;
TSRMLS_FETCH
();
RepeatedField
*
intern
=
(
RepeatedField
*
)
zend_object_store_get_object
(
array
TSRMLS_CC
);
...
...
@@ -296,8 +299,9 @@ static size_t stringdata_handler(void* closure, const void* hd,
}
// Appends a submessage to a repeated field.
static
void
*
appendsubmsg_handler
(
void
*
closure
,
const
void
*
hd
TSRMLS_DC
)
{
static
void
*
appendsubmsg_handler
(
void
*
closure
,
const
void
*
hd
)
{
zval
*
array
=
(
zval
*
)
closure
;
TSRMLS_FETCH
();
RepeatedField
*
intern
=
(
RepeatedField
*
)
zend_object_store_get_object
(
array
TSRMLS_CC
);
...
...
@@ -319,10 +323,11 @@ static void *appendsubmsg_handler(void *closure, const void *hd TSRMLS_DC) {
}
// Sets a non-repeated submessage field in a message.
static
void
*
submsg_handler
(
void
*
closure
,
const
void
*
hd
TSRMLS_DC
)
{
static
void
*
submsg_handler
(
void
*
closure
,
const
void
*
hd
)
{
MessageHeader
*
msg
=
closure
;
const
submsg_handlerdata_t
*
submsgdata
=
hd
;
zval
*
subdesc_php
=
get_def_obj
((
void
*
)
submsgdata
->
md
);
TSRMLS_FETCH
();
Descriptor
*
subdesc
=
zend_object_store_get_object
(
subdesc_php
TSRMLS_CC
);
zend_class_entry
*
subklass
=
subdesc
->
klass
;
zval
*
submsg_php
;
...
...
@@ -465,11 +470,11 @@ static void *startmapentry_handler(void *closure, const void *hd) {
// Handler to end a map entry: inserts the value defined during the message into
// the map. This is the 'endmsg' handler on the map entry msgdef.
static
bool
endmap_handler
(
void
*
closure
,
const
void
*
hd
,
upb_status
*
s
TSRMLS_DC
)
{
static
bool
endmap_handler
(
void
*
closure
,
const
void
*
hd
,
upb_status
*
s
)
{
map_parse_frame_t
*
frame
=
closure
;
const
map_handlerdata_t
*
mapdata
=
hd
;
TSRMLS_FETCH
();
Map
*
map
=
(
Map
*
)
zend_object_store_get_object
(
frame
->
map
TSRMLS_CC
);
const
char
*
keyval
=
NULL
;
...
...
@@ -575,12 +580,12 @@ static void *oneofbytes_handler(void *closure,
}
// Handler for a submessage field in a oneof.
static
void
*
oneofsubmsg_handler
(
void
*
closure
,
const
void
*
hd
TSRMLS_DC
)
{
static
void
*
oneofsubmsg_handler
(
void
*
closure
,
const
void
*
hd
)
{
MessageHeader
*
msg
=
closure
;
const
oneof_handlerdata_t
*
oneofdata
=
hd
;
uint32_t
oldcase
=
DEREF
(
msg
,
oneofdata
->
case_ofs
,
uint32_t
);
zval
*
subdesc_php
=
get_def_obj
((
void
*
)
oneofdata
->
md
);
TSRMLS_FETCH
();
Descriptor
*
subdesc
=
zend_object_store_get_object
(
subdesc_php
TSRMLS_CC
);
zend_class_entry
*
subklass
=
subdesc
->
klass
;
zval
*
submsg_php
;
...
...
@@ -773,9 +778,10 @@ static void add_handlers_for_oneof_field(upb_handlers *h,
upb_handlerattr_uninit
(
&
attr
);
}
static
void
add_handlers_for_message
(
const
void
*
closure
,
upb_handlers
*
h
TSRMLS_DC
)
{
static
void
add_handlers_for_message
(
const
void
*
closure
,
upb_handlers
*
h
)
{
const
upb_msgdef
*
msgdef
=
upb_handlers_msgdef
(
h
);
TSRMLS_FETCH
();
Descriptor
*
desc
=
(
Descriptor
*
)
zend_object_store_get_object
(
get_def_obj
((
void
*
)
msgdef
)
TSRMLS_CC
);
upb_msg_field_iter
i
;
...
...
php/ext/google/protobuf/type_check.c
View file @
75b69887
...
...
@@ -214,7 +214,6 @@ bool protobuf_convert_to_bool(zval* from, int8_t* to) {
}
else
{
*
to
=
1
;
}
STR_FREE
(
strval
);
}
break
;
default:
{
zend_error
(
E_USER_ERROR
,
"Given value cannot be converted to bool."
);
...
...
php/tests/array_test.php
View file @
75b69887
...
...
@@ -789,26 +789,26 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase
$this
->
assertSame
(
1
,
count
(
$arr
));
}
public
function
testInsertRemoval
()
{
$arr
=
new
RepeatedField
(
GPBType
::
INT32
);
$arr
[]
=
0
;
$arr
[]
=
1
;
$arr
[]
=
2
;
$this
->
assertSame
(
3
,
count
(
$arr
));
unset
(
$arr
[
2
]);
$this
->
assertSame
(
2
,
count
(
$arr
));
$this
->
assertSame
(
0
,
$arr
[
0
]);
$this
->
assertSame
(
1
,
$arr
[
1
]);
$arr
[]
=
3
;
$this
->
assertSame
(
3
,
count
(
$arr
));
$this
->
assertSame
(
0
,
$arr
[
0
]);
$this
->
assertSame
(
1
,
$arr
[
1
]);
$this
->
assertSame
(
3
,
$arr
[
2
]);
}
public
function
testInsertRemoval
()
{
$arr
=
new
RepeatedField
(
GPBType
::
INT32
);
$arr
[]
=
0
;
$arr
[]
=
1
;
$arr
[]
=
2
;
$this
->
assertSame
(
3
,
count
(
$arr
));
unset
(
$arr
[
2
]);
$this
->
assertSame
(
2
,
count
(
$arr
));
$this
->
assertSame
(
0
,
$arr
[
0
]);
$this
->
assertSame
(
1
,
$arr
[
1
]);
$arr
[]
=
3
;
$this
->
assertSame
(
3
,
count
(
$arr
));
$this
->
assertSame
(
0
,
$arr
[
0
]);
$this
->
assertSame
(
1
,
$arr
[
1
]);
$this
->
assertSame
(
3
,
$arr
[
2
]);
}
/**
* @expectedException PHPUnit_Framework_Error
...
...
tests.sh
View file @
75b69887
...
...
@@ -377,6 +377,7 @@ build_php5.5_mac() {
build_php5.5_zts_c
()
{
use_php_zts 5.5
wget https://phar.phpunit.de/phpunit-old.phar
-O
/usr/bin/phpunit
cd
php/tests
&&
/bin/bash ./test.sh
&&
cd
../..
}
...
...
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