Skip to content

Commit

Permalink
Fixed bug #72658 Locale::lookup() / locale_lookup() hangs if no match…
Browse files Browse the repository at this point in the history
… found
  • Loading branch information
weltling committed Jul 25, 2016
1 parent ee07e23 commit bd9a5b1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ext/intl/locale/locale_methods.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ static char* getPreferredTag(const char* gf_tag)
* or -1 if no token
* strtokr equivalent search for token in reverse direction
*/
static int getStrrtokenPos(char* str, int savedPos)
static zend_off_t getStrrtokenPos(char* str, zend_off_t savedPos)
{
int result =-1;
int i;
zend_off_t result =-1;
zend_off_t i;

for(i=savedPos-1; i>=0; i--) {
if(isIDSeparator(*(str+i)) ){
Expand Down Expand Up @@ -1429,7 +1429,7 @@ static zend_string* lookup_loc_range(const char* loc_range, HashTable* hash_arr,

char* cur_loc_range = NULL;
zend_string* can_loc_range = NULL;
size_t saved_pos = 0;
zend_off_t saved_pos = 0;

zend_string* return_value = NULL;

Expand Down
18 changes: 18 additions & 0 deletions ext/intl/tests/locale_bug72658.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
Bug #72658 Locale::lookup() / locale_lookup() hangs if no match found
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
--FILE--
<?php

var_dump(
Locale::lookup(['en-Latn-US', 'sl', 'sl-IT'], 'en-US', true, 'de-DE'),
Locale::lookup(['en-Latn-US', 'sl', 'sl-IT'], 'en-US', false, 'de-DE')
);

?>
==DONE==
--EXPECT--
string(5) "de-DE"
string(5) "de-DE"
==DONE==

0 comments on commit bd9a5b1

Please sign in to comment.