Skip to content

Commit 88bfd2a

Browse files
committed
Regroup expressions in php_schema.c to avoid array bounds warnings
1 parent edcf087 commit 88bfd2a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ext/soap/php_schema.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ static int schema_list(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr listType, sdlTypeP
458458
{
459459
char buf[MAX_LENGTH_OF_LONG + 1];
460460
char *res = zend_print_long_to_buf(buf + sizeof(buf) - 1, zend_hash_num_elements(sdl->types));
461-
char *str = emalloc(sizeof("anonymous") + buf + sizeof(buf) - 1 - res);
461+
char *str = emalloc(sizeof("anonymous")-1 + (buf + sizeof(buf) - res));
462462

463463
memcpy(str, "anonymous", sizeof("anonymous")-1);
464464
memcpy(str + sizeof("anonymous")-1, res, buf + sizeof(buf) - res);
@@ -555,7 +555,7 @@ static int schema_union(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr unionType, sdlTyp
555555
{
556556
char buf[MAX_LENGTH_OF_LONG + 1];
557557
char *res = zend_print_long_to_buf(buf + sizeof(buf) - 1, zend_hash_num_elements(sdl->types));
558-
char *str = emalloc(sizeof("anonymous") + buf + sizeof(buf) - 1 - res);
558+
char *str = emalloc(sizeof("anonymous")-1 + (buf + sizeof(buf) - res));
559559

560560
memcpy(str, "anonymous", sizeof("anonymous")-1);
561561
memcpy(str + sizeof("anonymous")-1, res, buf + sizeof(buf) - res);
@@ -1799,6 +1799,7 @@ static int schema_attribute(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr attrType, sdl
17991799
smart_str_free(&key);
18001800
} else{
18011801
soap_error0(E_ERROR, "Parsing Schema: attribute has no 'name' nor 'ref' attributes");
1802+
return FALSE; /* the above call is noreturn, but not marked as such */
18021803
}
18031804

18041805
/* type = QName */
@@ -1927,7 +1928,7 @@ static int schema_attribute(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr attrType, sdl
19271928
{
19281929
char buf[MAX_LENGTH_OF_LONG + 1];
19291930
char *res = zend_print_long_to_buf(buf + sizeof(buf) - 1, zend_hash_num_elements(sdl->types));
1930-
char *str = emalloc(sizeof("anonymous") + buf + sizeof(buf) - 1 - res);
1931+
char *str = emalloc(sizeof("anonymous")-1 + (buf + sizeof(buf) - res));
19311932

19321933
memcpy(str, "anonymous", sizeof("anonymous")-1);
19331934
memcpy(str + sizeof("anonymous")-1, res, buf + sizeof(buf) - res);

0 commit comments

Comments
 (0)