var_unserializer.c 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331
  1. /* Generated by re2c 0.15.3 */
  2. /*
  3. +----------------------------------------------------------------------+
  4. | PHP Version 5 |
  5. +----------------------------------------------------------------------+
  6. | Copyright (c) 1997-2016 The PHP Group |
  7. +----------------------------------------------------------------------+
  8. | This source file is subject to version 3.01 of the PHP license, |
  9. | that is bundled with this package in the file LICENSE, and is |
  10. | available through the world-wide-web at the following url: |
  11. | http://www.php.net/license/3_01.txt |
  12. | If you did not receive a copy of the PHP license and are unable to |
  13. | obtain it through the world-wide-web, please send a note to |
  14. | license@php.net so we can mail you a copy immediately. |
  15. +----------------------------------------------------------------------+
  16. | Author: Sascha Schumann <sascha@schumann.cx> |
  17. +----------------------------------------------------------------------+
  18. */
  19. /* $Id$ */
  20. #include "php.h"
  21. #include "ext/standard/php_var.h"
  22. #include "php_incomplete_class.h"
  23. /* {{{ reference-handling for unserializer: var_* */
  24. #define VAR_ENTRIES_MAX 1024
  25. #define VAR_ENTRIES_DBG 0
  26. #define VAR_WAKEUP_FLAG 1
  27. #define WITH_WAKEUP_FLAG(zv_ptr) ((zval *) ((zend_uintptr_t) zv_ptr | VAR_WAKEUP_FLAG))
  28. #define WITHOUT_WAKEUP_FLAG(zv_ptr) ((zval *) ((zend_uintptr_t) zv_ptr & ~VAR_WAKEUP_FLAG))
  29. #define HAS_WAKEUP_FLAG(zv_ptr) ((zend_uintptr_t) zv_ptr & VAR_WAKEUP_FLAG)
  30. typedef struct {
  31. zval *data[VAR_ENTRIES_MAX];
  32. long used_slots;
  33. void *next;
  34. } var_entries;
  35. static inline void var_push(php_unserialize_data_t *var_hashx, zval **rval)
  36. {
  37. var_entries *var_hash = (*var_hashx)->last;
  38. #if VAR_ENTRIES_DBG
  39. fprintf(stderr, "var_push(%ld): %d\n", var_hash?var_hash->used_slots:-1L, Z_TYPE_PP(rval));
  40. #endif
  41. if (!var_hash || var_hash->used_slots == VAR_ENTRIES_MAX) {
  42. var_hash = emalloc(sizeof(var_entries));
  43. var_hash->used_slots = 0;
  44. var_hash->next = 0;
  45. if (!(*var_hashx)->first) {
  46. (*var_hashx)->first = var_hash;
  47. } else {
  48. ((var_entries *) (*var_hashx)->last)->next = var_hash;
  49. }
  50. (*var_hashx)->last = var_hash;
  51. }
  52. var_hash->data[var_hash->used_slots++] = *rval;
  53. }
  54. static inline zval **get_var_push_dtor_slot(php_unserialize_data_t *var_hashx)
  55. {
  56. var_entries *var_hash;
  57. if (!var_hashx || !*var_hashx) {
  58. return NULL;
  59. }
  60. var_hash = (*var_hashx)->last_dtor;
  61. #if VAR_ENTRIES_DBG
  62. fprintf(stderr, "var_push_dtor(%p, %ld): %d\n", *rval, var_hash?var_hash->used_slots:-1L, Z_TYPE_PP(rval));
  63. #endif
  64. if (!var_hash || var_hash->used_slots == VAR_ENTRIES_MAX) {
  65. var_hash = emalloc(sizeof(var_entries));
  66. var_hash->used_slots = 0;
  67. var_hash->next = 0;
  68. if (!(*var_hashx)->first_dtor) {
  69. (*var_hashx)->first_dtor = var_hash;
  70. } else {
  71. ((var_entries *) (*var_hashx)->last_dtor)->next = var_hash;
  72. }
  73. (*var_hashx)->last_dtor = var_hash;
  74. }
  75. return &var_hash->data[var_hash->used_slots++];
  76. }
  77. PHPAPI void var_push_dtor(php_unserialize_data_t *var_hashx, zval **rval)
  78. {
  79. zval **slot = get_var_push_dtor_slot(var_hashx);
  80. Z_ADDREF_PP(rval);
  81. *slot = *rval;
  82. }
  83. PHPAPI void var_push_dtor_no_addref(php_unserialize_data_t *var_hashx, zval **rval)
  84. {
  85. var_entries *var_hash;
  86. if (!var_hashx || !*var_hashx) {
  87. return;
  88. }
  89. var_hash = (*var_hashx)->last_dtor;
  90. #if VAR_ENTRIES_DBG
  91. fprintf(stderr, "var_push_dtor_no_addref(%p, %ld): %d (%d)\n", *rval, var_hash?var_hash->used_slots:-1L, Z_TYPE_PP(rval), Z_REFCOUNT_PP(rval));
  92. #endif
  93. if (!var_hash || var_hash->used_slots == VAR_ENTRIES_MAX) {
  94. var_hash = emalloc(sizeof(var_entries));
  95. var_hash->used_slots = 0;
  96. var_hash->next = 0;
  97. if (!(*var_hashx)->first_dtor) {
  98. (*var_hashx)->first_dtor = var_hash;
  99. } else {
  100. ((var_entries *) (*var_hashx)->last_dtor)->next = var_hash;
  101. }
  102. (*var_hashx)->last_dtor = var_hash;
  103. }
  104. var_hash->data[var_hash->used_slots++] = *rval;
  105. }
  106. PHPAPI void var_replace(php_unserialize_data_t *var_hashx, zval *ozval, zval **nzval)
  107. {
  108. long i;
  109. var_entries *var_hash = (*var_hashx)->first;
  110. #if VAR_ENTRIES_DBG
  111. fprintf(stderr, "var_replace(%ld): %d\n", var_hash?var_hash->used_slots:-1L, Z_TYPE_PP(nzval));
  112. #endif
  113. while (var_hash) {
  114. for (i = 0; i < var_hash->used_slots; i++) {
  115. if (var_hash->data[i] == ozval) {
  116. var_hash->data[i] = *nzval;
  117. /* do not break here */
  118. }
  119. }
  120. var_hash = var_hash->next;
  121. }
  122. }
  123. static int var_access(php_unserialize_data_t *var_hashx, long id, zval ***store)
  124. {
  125. var_entries *var_hash = (*var_hashx)->first;
  126. #if VAR_ENTRIES_DBG
  127. fprintf(stderr, "var_access(%ld): %ld\n", var_hash?var_hash->used_slots:-1L, id);
  128. #endif
  129. while (id >= VAR_ENTRIES_MAX && var_hash && var_hash->used_slots == VAR_ENTRIES_MAX) {
  130. var_hash = var_hash->next;
  131. id -= VAR_ENTRIES_MAX;
  132. }
  133. if (!var_hash) return !SUCCESS;
  134. if (id < 0 || id >= var_hash->used_slots) return !SUCCESS;
  135. *store = &var_hash->data[id];
  136. return SUCCESS;
  137. }
  138. PHPAPI void var_destroy(php_unserialize_data_t *var_hashx)
  139. {
  140. void *next;
  141. long i;
  142. var_entries *var_hash = (*var_hashx)->first;
  143. zend_bool wakeup_failed = 0;
  144. TSRMLS_FETCH();
  145. #if VAR_ENTRIES_DBG
  146. fprintf(stderr, "var_destroy(%ld)\n", var_hash?var_hash->used_slots:-1L);
  147. #endif
  148. while (var_hash) {
  149. next = var_hash->next;
  150. efree(var_hash);
  151. var_hash = next;
  152. }
  153. var_hash = (*var_hashx)->first_dtor;
  154. while (var_hash) {
  155. for (i = 0; i < var_hash->used_slots; i++) {
  156. zval *zv = var_hash->data[i];
  157. #if VAR_ENTRIES_DBG
  158. fprintf(stderr, "var_destroy dtor(%p, %ld)\n", var_hash->data[i], Z_REFCOUNT_P(var_hash->data[i]));
  159. #endif
  160. if (HAS_WAKEUP_FLAG(zv)) {
  161. zv = WITHOUT_WAKEUP_FLAG(zv);
  162. if (!wakeup_failed) {
  163. zval *retval_ptr = NULL;
  164. zval wakeup_name;
  165. INIT_PZVAL(&wakeup_name);
  166. ZVAL_STRINGL(&wakeup_name, "__wakeup", sizeof("__wakeup") - 1, 0);
  167. BG(serialize_lock)++;
  168. if (call_user_function_ex(CG(function_table), &zv, &wakeup_name, &retval_ptr, 0, 0, 1, NULL TSRMLS_CC) == FAILURE || retval_ptr == NULL) {
  169. wakeup_failed = 1;
  170. zend_object_store_ctor_failed(zv TSRMLS_CC);
  171. }
  172. BG(serialize_lock)--;
  173. if (retval_ptr) {
  174. zval_ptr_dtor(&retval_ptr);
  175. }
  176. } else {
  177. zend_object_store_ctor_failed(zv TSRMLS_CC);
  178. }
  179. }
  180. zval_ptr_dtor(&zv);
  181. }
  182. next = var_hash->next;
  183. efree(var_hash);
  184. var_hash = next;
  185. }
  186. }
  187. /* }}} */
  188. static char *unserialize_str(const unsigned char **p, size_t *len, size_t maxlen)
  189. {
  190. size_t i, j;
  191. char *str = safe_emalloc(*len, 1, 1);
  192. unsigned char *end = *(unsigned char **)p+maxlen;
  193. if (end < *p) {
  194. efree(str);
  195. return NULL;
  196. }
  197. for (i = 0; i < *len; i++) {
  198. if (*p >= end) {
  199. efree(str);
  200. return NULL;
  201. }
  202. if (**p != '\\') {
  203. str[i] = (char)**p;
  204. } else {
  205. unsigned char ch = 0;
  206. for (j = 0; j < 2; j++) {
  207. (*p)++;
  208. if (**p >= '0' && **p <= '9') {
  209. ch = (ch << 4) + (**p -'0');
  210. } else if (**p >= 'a' && **p <= 'f') {
  211. ch = (ch << 4) + (**p -'a'+10);
  212. } else if (**p >= 'A' && **p <= 'F') {
  213. ch = (ch << 4) + (**p -'A'+10);
  214. } else {
  215. efree(str);
  216. return NULL;
  217. }
  218. }
  219. str[i] = (char)ch;
  220. }
  221. (*p)++;
  222. }
  223. str[i] = 0;
  224. *len = i;
  225. return str;
  226. }
  227. #define YYFILL(n) do { } while (0)
  228. #define YYCTYPE unsigned char
  229. #define YYCURSOR cursor
  230. #define YYLIMIT limit
  231. #define YYMARKER marker
  232. static inline long parse_iv2(const unsigned char *p, const unsigned char **q)
  233. {
  234. char cursor;
  235. long result = 0;
  236. int neg = 0;
  237. switch (*p) {
  238. case '-':
  239. neg++;
  240. /* fall-through */
  241. case '+':
  242. p++;
  243. }
  244. while (1) {
  245. cursor = (char)*p;
  246. if (cursor >= '0' && cursor <= '9') {
  247. result = result * 10 + (size_t)(cursor - (unsigned char)'0');
  248. } else {
  249. break;
  250. }
  251. p++;
  252. }
  253. if (q) *q = p;
  254. if (neg) return -result;
  255. return result;
  256. }
  257. static inline long parse_iv(const unsigned char *p)
  258. {
  259. return parse_iv2(p, NULL);
  260. }
  261. /* no need to check for length - re2c already did */
  262. static inline size_t parse_uiv(const unsigned char *p)
  263. {
  264. unsigned char cursor;
  265. size_t result = 0;
  266. if (*p == '+') {
  267. p++;
  268. }
  269. while (1) {
  270. cursor = *p;
  271. if (cursor >= '0' && cursor <= '9') {
  272. result = result * 10 + (size_t)(cursor - (unsigned char)'0');
  273. } else {
  274. break;
  275. }
  276. p++;
  277. }
  278. return result;
  279. }
  280. #define UNSERIALIZE_PARAMETER zval **rval, const unsigned char **p, const unsigned char *max, php_unserialize_data_t *var_hash TSRMLS_DC
  281. #define UNSERIALIZE_PASSTHRU rval, p, max, var_hash TSRMLS_CC
  282. static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long elements, int objprops)
  283. {
  284. while (elements-- > 0) {
  285. zval *key, *data, **old_data;
  286. ALLOC_INIT_ZVAL(key);
  287. if (!php_var_unserialize(&key, p, max, NULL TSRMLS_CC)) {
  288. var_push_dtor_no_addref(var_hash, &key);
  289. return 0;
  290. }
  291. if (Z_TYPE_P(key) != IS_LONG && Z_TYPE_P(key) != IS_STRING) {
  292. var_push_dtor_no_addref(var_hash, &key);
  293. return 0;
  294. }
  295. ALLOC_INIT_ZVAL(data);
  296. if (!php_var_unserialize(&data, p, max, var_hash TSRMLS_CC)) {
  297. var_push_dtor_no_addref(var_hash, &key);
  298. var_push_dtor_no_addref(var_hash, &data);
  299. return 0;
  300. }
  301. if (!objprops) {
  302. switch (Z_TYPE_P(key)) {
  303. case IS_LONG:
  304. if (zend_hash_index_find(ht, Z_LVAL_P(key), (void **)&old_data)==SUCCESS) {
  305. var_push_dtor(var_hash, old_data);
  306. }
  307. zend_hash_index_update(ht, Z_LVAL_P(key), &data, sizeof(data), NULL);
  308. break;
  309. case IS_STRING:
  310. if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
  311. var_push_dtor(var_hash, old_data);
  312. }
  313. zend_symtable_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data, sizeof(data), NULL);
  314. break;
  315. }
  316. } else {
  317. /* object properties should include no integers */
  318. convert_to_string(key);
  319. if (zend_hash_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
  320. var_push_dtor(var_hash, old_data);
  321. }
  322. zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data,
  323. sizeof data, NULL);
  324. }
  325. var_push_dtor(var_hash, &data);
  326. var_push_dtor_no_addref(var_hash, &key);
  327. if (elements && *(*p-1) != ';' && *(*p-1) != '}') {
  328. (*p)--;
  329. return 0;
  330. }
  331. }
  332. return 1;
  333. }
  334. static inline int finish_nested_data(UNSERIALIZE_PARAMETER)
  335. {
  336. if (*p >= max || **p != '}') {
  337. return 0;
  338. }
  339. (*p)++;
  340. return 1;
  341. }
  342. static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
  343. {
  344. long datalen;
  345. datalen = parse_iv2((*p) + 2, p);
  346. (*p) += 2;
  347. if (datalen < 0 || (max - (*p)) <= datalen) {
  348. zend_error(E_WARNING, "Insufficient data for unserializing - %ld required, %ld present", datalen, (long)(max - (*p)));
  349. return 0;
  350. }
  351. if (ce->unserialize == NULL) {
  352. zend_error(E_WARNING, "Class %s has no unserializer", ce->name);
  353. object_init_ex(*rval, ce);
  354. } else if (ce->unserialize(rval, ce, (const unsigned char*)*p, datalen, (zend_unserialize_data *)var_hash TSRMLS_CC) != SUCCESS) {
  355. return 0;
  356. }
  357. (*p) += datalen;
  358. return finish_nested_data(UNSERIALIZE_PASSTHRU);
  359. }
  360. static inline long object_common1(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
  361. {
  362. long elements;
  363. if( *p >= max - 2) {
  364. zend_error(E_WARNING, "Bad unserialize data");
  365. return -1;
  366. }
  367. elements = parse_iv2((*p) + 2, p);
  368. (*p) += 2;
  369. if (ce->serialize == NULL) {
  370. object_init_ex(*rval, ce);
  371. } else {
  372. /* If this class implements Serializable, it should not land here but in object_custom(). The passed string
  373. obviously doesn't descend from the regular serializer. */
  374. zend_error(E_WARNING, "Erroneous data format for unserializing '%s'", ce->name);
  375. return -1;
  376. }
  377. return elements;
  378. }
  379. #ifdef PHP_WIN32
  380. # pragma optimize("", off)
  381. #endif
  382. static inline int object_common2(UNSERIALIZE_PARAMETER, long elements)
  383. {
  384. if (Z_TYPE_PP(rval) != IS_OBJECT) {
  385. return 0;
  386. }
  387. if (!process_nested_data(UNSERIALIZE_PASSTHRU, Z_OBJPROP_PP(rval), elements, 1)) {
  388. /* We've got partially constructed object on our hands here. Wipe it. */
  389. if (Z_TYPE_PP(rval) == IS_OBJECT) {
  390. zend_hash_clean(Z_OBJPROP_PP(rval));
  391. zend_object_store_ctor_failed(*rval TSRMLS_CC);
  392. }
  393. ZVAL_NULL(*rval);
  394. return 0;
  395. }
  396. if (Z_TYPE_PP(rval) != IS_OBJECT) {
  397. return 0;
  398. }
  399. if (Z_OBJCE_PP(rval) != PHP_IC_ENTRY &&
  400. zend_hash_exists(&Z_OBJCE_PP(rval)->function_table, "__wakeup", sizeof("__wakeup"))
  401. ) {
  402. /* Store object for delayed __wakeup call. Remove references. */
  403. zval **slot = get_var_push_dtor_slot(var_hash);
  404. zval *zv = *rval;
  405. Z_ADDREF_P(zv);
  406. if (PZVAL_IS_REF(zv)) {
  407. SEPARATE_ZVAL(&zv);
  408. }
  409. *slot = WITH_WAKEUP_FLAG(zv);
  410. }
  411. return finish_nested_data(UNSERIALIZE_PASSTHRU);
  412. }
  413. #ifdef PHP_WIN32
  414. # pragma optimize("", on)
  415. #endif
  416. PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
  417. {
  418. const unsigned char *cursor, *limit, *marker, *start;
  419. zval **rval_ref;
  420. limit = max;
  421. cursor = *p;
  422. if (YYCURSOR >= YYLIMIT) {
  423. return 0;
  424. }
  425. if (var_hash && cursor[0] != 'R') {
  426. var_push(var_hash, rval);
  427. }
  428. start = cursor;
  429. {
  430. YYCTYPE yych;
  431. static const unsigned char yybm[] = {
  432. 0, 0, 0, 0, 0, 0, 0, 0,
  433. 0, 0, 0, 0, 0, 0, 0, 0,
  434. 0, 0, 0, 0, 0, 0, 0, 0,
  435. 0, 0, 0, 0, 0, 0, 0, 0,
  436. 0, 0, 0, 0, 0, 0, 0, 0,
  437. 0, 0, 0, 0, 0, 0, 0, 0,
  438. 128, 128, 128, 128, 128, 128, 128, 128,
  439. 128, 128, 0, 0, 0, 0, 0, 0,
  440. 0, 0, 0, 0, 0, 0, 0, 0,
  441. 0, 0, 0, 0, 0, 0, 0, 0,
  442. 0, 0, 0, 0, 0, 0, 0, 0,
  443. 0, 0, 0, 0, 0, 0, 0, 0,
  444. 0, 0, 0, 0, 0, 0, 0, 0,
  445. 0, 0, 0, 0, 0, 0, 0, 0,
  446. 0, 0, 0, 0, 0, 0, 0, 0,
  447. 0, 0, 0, 0, 0, 0, 0, 0,
  448. 0, 0, 0, 0, 0, 0, 0, 0,
  449. 0, 0, 0, 0, 0, 0, 0, 0,
  450. 0, 0, 0, 0, 0, 0, 0, 0,
  451. 0, 0, 0, 0, 0, 0, 0, 0,
  452. 0, 0, 0, 0, 0, 0, 0, 0,
  453. 0, 0, 0, 0, 0, 0, 0, 0,
  454. 0, 0, 0, 0, 0, 0, 0, 0,
  455. 0, 0, 0, 0, 0, 0, 0, 0,
  456. 0, 0, 0, 0, 0, 0, 0, 0,
  457. 0, 0, 0, 0, 0, 0, 0, 0,
  458. 0, 0, 0, 0, 0, 0, 0, 0,
  459. 0, 0, 0, 0, 0, 0, 0, 0,
  460. 0, 0, 0, 0, 0, 0, 0, 0,
  461. 0, 0, 0, 0, 0, 0, 0, 0,
  462. 0, 0, 0, 0, 0, 0, 0, 0,
  463. 0, 0, 0, 0, 0, 0, 0, 0,
  464. };
  465. if ((YYLIMIT - YYCURSOR) < 7) YYFILL(7);
  466. yych = *YYCURSOR;
  467. switch (yych) {
  468. case 'C':
  469. case 'O': goto yy13;
  470. case 'N': goto yy5;
  471. case 'R': goto yy2;
  472. case 'S': goto yy10;
  473. case 'a': goto yy11;
  474. case 'b': goto yy6;
  475. case 'd': goto yy8;
  476. case 'i': goto yy7;
  477. case 'o': goto yy12;
  478. case 'r': goto yy4;
  479. case 's': goto yy9;
  480. case '}': goto yy14;
  481. default: goto yy16;
  482. }
  483. yy2:
  484. yych = *(YYMARKER = ++YYCURSOR);
  485. if (yych == ':') goto yy95;
  486. yy3:
  487. { return 0; }
  488. yy4:
  489. yych = *(YYMARKER = ++YYCURSOR);
  490. if (yych == ':') goto yy89;
  491. goto yy3;
  492. yy5:
  493. yych = *++YYCURSOR;
  494. if (yych == ';') goto yy87;
  495. goto yy3;
  496. yy6:
  497. yych = *(YYMARKER = ++YYCURSOR);
  498. if (yych == ':') goto yy83;
  499. goto yy3;
  500. yy7:
  501. yych = *(YYMARKER = ++YYCURSOR);
  502. if (yych == ':') goto yy77;
  503. goto yy3;
  504. yy8:
  505. yych = *(YYMARKER = ++YYCURSOR);
  506. if (yych == ':') goto yy53;
  507. goto yy3;
  508. yy9:
  509. yych = *(YYMARKER = ++YYCURSOR);
  510. if (yych == ':') goto yy46;
  511. goto yy3;
  512. yy10:
  513. yych = *(YYMARKER = ++YYCURSOR);
  514. if (yych == ':') goto yy39;
  515. goto yy3;
  516. yy11:
  517. yych = *(YYMARKER = ++YYCURSOR);
  518. if (yych == ':') goto yy32;
  519. goto yy3;
  520. yy12:
  521. yych = *(YYMARKER = ++YYCURSOR);
  522. if (yych == ':') goto yy25;
  523. goto yy3;
  524. yy13:
  525. yych = *(YYMARKER = ++YYCURSOR);
  526. if (yych == ':') goto yy17;
  527. goto yy3;
  528. yy14:
  529. ++YYCURSOR;
  530. {
  531. /* this is the case where we have less data than planned */
  532. php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unexpected end of serialized data");
  533. return 0; /* not sure if it should be 0 or 1 here? */
  534. }
  535. yy16:
  536. yych = *++YYCURSOR;
  537. goto yy3;
  538. yy17:
  539. yych = *++YYCURSOR;
  540. if (yybm[0+yych] & 128) {
  541. goto yy20;
  542. }
  543. if (yych == '+') goto yy19;
  544. yy18:
  545. YYCURSOR = YYMARKER;
  546. goto yy3;
  547. yy19:
  548. yych = *++YYCURSOR;
  549. if (yybm[0+yych] & 128) {
  550. goto yy20;
  551. }
  552. goto yy18;
  553. yy20:
  554. ++YYCURSOR;
  555. if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
  556. yych = *YYCURSOR;
  557. if (yybm[0+yych] & 128) {
  558. goto yy20;
  559. }
  560. if (yych <= '/') goto yy18;
  561. if (yych >= ';') goto yy18;
  562. yych = *++YYCURSOR;
  563. if (yych != '"') goto yy18;
  564. ++YYCURSOR;
  565. {
  566. size_t len, len2, len3, maxlen;
  567. long elements;
  568. char *class_name;
  569. zend_class_entry *ce;
  570. zend_class_entry **pce;
  571. int incomplete_class = 0;
  572. int custom_object = 0;
  573. zval *user_func;
  574. zval *retval_ptr;
  575. zval **args[1];
  576. zval *arg_func_name;
  577. if (!var_hash) return 0;
  578. if (*start == 'C') {
  579. custom_object = 1;
  580. }
  581. INIT_PZVAL(*rval);
  582. len2 = len = parse_uiv(start + 2);
  583. maxlen = max - YYCURSOR;
  584. if (maxlen < len || len == 0) {
  585. *p = start + 2;
  586. return 0;
  587. }
  588. class_name = (char*)YYCURSOR;
  589. YYCURSOR += len;
  590. if (*(YYCURSOR) != '"') {
  591. *p = YYCURSOR;
  592. return 0;
  593. }
  594. if (*(YYCURSOR+1) != ':') {
  595. *p = YYCURSOR+1;
  596. return 0;
  597. }
  598. len3 = strspn(class_name, "0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\\");
  599. if (len3 != len)
  600. {
  601. *p = YYCURSOR + len3 - len;
  602. return 0;
  603. }
  604. class_name = estrndup(class_name, len);
  605. do {
  606. /* Try to find class directly */
  607. BG(serialize_lock)++;
  608. if (zend_lookup_class(class_name, len2, &pce TSRMLS_CC) == SUCCESS) {
  609. BG(serialize_lock)--;
  610. if (EG(exception)) {
  611. efree(class_name);
  612. return 0;
  613. }
  614. ce = *pce;
  615. break;
  616. }
  617. BG(serialize_lock)--;
  618. if (EG(exception)) {
  619. efree(class_name);
  620. return 0;
  621. }
  622. /* Check for unserialize callback */
  623. if ((PG(unserialize_callback_func) == NULL) || (PG(unserialize_callback_func)[0] == '\0')) {
  624. incomplete_class = 1;
  625. ce = PHP_IC_ENTRY;
  626. break;
  627. }
  628. /* Call unserialize callback */
  629. MAKE_STD_ZVAL(user_func);
  630. ZVAL_STRING(user_func, PG(unserialize_callback_func), 1);
  631. args[0] = &arg_func_name;
  632. MAKE_STD_ZVAL(arg_func_name);
  633. ZVAL_STRING(arg_func_name, class_name, 1);
  634. BG(serialize_lock)++;
  635. if (call_user_function_ex(CG(function_table), NULL, user_func, &retval_ptr, 1, args, 0, NULL TSRMLS_CC) != SUCCESS) {
  636. BG(serialize_lock)--;
  637. if (EG(exception)) {
  638. efree(class_name);
  639. zval_ptr_dtor(&user_func);
  640. zval_ptr_dtor(&arg_func_name);
  641. return 0;
  642. }
  643. php_error_docref(NULL TSRMLS_CC, E_WARNING, "defined (%s) but not found", user_func->value.str.val);
  644. incomplete_class = 1;
  645. ce = PHP_IC_ENTRY;
  646. zval_ptr_dtor(&user_func);
  647. zval_ptr_dtor(&arg_func_name);
  648. break;
  649. }
  650. BG(serialize_lock)--;
  651. if (retval_ptr) {
  652. zval_ptr_dtor(&retval_ptr);
  653. }
  654. if (EG(exception)) {
  655. efree(class_name);
  656. zval_ptr_dtor(&user_func);
  657. zval_ptr_dtor(&arg_func_name);
  658. return 0;
  659. }
  660. /* The callback function may have defined the class */
  661. BG(serialize_lock)++;
  662. if (zend_lookup_class(class_name, len2, &pce TSRMLS_CC) == SUCCESS) {
  663. ce = *pce;
  664. } else {
  665. php_error_docref(NULL TSRMLS_CC, E_WARNING, "Function %s() hasn't defined the class it was called for", user_func->value.str.val);
  666. incomplete_class = 1;
  667. ce = PHP_IC_ENTRY;
  668. }
  669. BG(serialize_lock)--;
  670. zval_ptr_dtor(&user_func);
  671. zval_ptr_dtor(&arg_func_name);
  672. break;
  673. } while (1);
  674. *p = YYCURSOR;
  675. if (custom_object) {
  676. int ret;
  677. ret = object_custom(UNSERIALIZE_PASSTHRU, ce);
  678. if (ret && incomplete_class) {
  679. php_store_class_name(*rval, class_name, len2);
  680. }
  681. efree(class_name);
  682. return ret;
  683. }
  684. elements = object_common1(UNSERIALIZE_PASSTHRU, ce);
  685. if (elements < 0) {
  686. efree(class_name);
  687. return 0;
  688. }
  689. if (incomplete_class) {
  690. php_store_class_name(*rval, class_name, len2);
  691. }
  692. efree(class_name);
  693. return object_common2(UNSERIALIZE_PASSTHRU, elements);
  694. }
  695. yy25:
  696. yych = *++YYCURSOR;
  697. if (yych <= ',') {
  698. if (yych != '+') goto yy18;
  699. } else {
  700. if (yych <= '-') goto yy26;
  701. if (yych <= '/') goto yy18;
  702. if (yych <= '9') goto yy27;
  703. goto yy18;
  704. }
  705. yy26:
  706. yych = *++YYCURSOR;
  707. if (yych <= '/') goto yy18;
  708. if (yych >= ':') goto yy18;
  709. yy27:
  710. ++YYCURSOR;
  711. if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
  712. yych = *YYCURSOR;
  713. if (yych <= '/') goto yy18;
  714. if (yych <= '9') goto yy27;
  715. if (yych >= ';') goto yy18;
  716. yych = *++YYCURSOR;
  717. if (yych != '"') goto yy18;
  718. ++YYCURSOR;
  719. {
  720. long elements;
  721. if (!var_hash) return 0;
  722. INIT_PZVAL(*rval);
  723. elements = object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR);
  724. if (elements < 0) {
  725. return 0;
  726. }
  727. return object_common2(UNSERIALIZE_PASSTHRU, elements);
  728. }
  729. yy32:
  730. yych = *++YYCURSOR;
  731. if (yych == '+') goto yy33;
  732. if (yych <= '/') goto yy18;
  733. if (yych <= '9') goto yy34;
  734. goto yy18;
  735. yy33:
  736. yych = *++YYCURSOR;
  737. if (yych <= '/') goto yy18;
  738. if (yych >= ':') goto yy18;
  739. yy34:
  740. ++YYCURSOR;
  741. if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
  742. yych = *YYCURSOR;
  743. if (yych <= '/') goto yy18;
  744. if (yych <= '9') goto yy34;
  745. if (yych >= ';') goto yy18;
  746. yych = *++YYCURSOR;
  747. if (yych != '{') goto yy18;
  748. ++YYCURSOR;
  749. {
  750. long elements = parse_iv(start + 2);
  751. /* use iv() not uiv() in order to check data range */
  752. *p = YYCURSOR;
  753. if (!var_hash) return 0;
  754. if (elements < 0) {
  755. return 0;
  756. }
  757. INIT_PZVAL(*rval);
  758. array_init_size(*rval, elements);
  759. if (!process_nested_data(UNSERIALIZE_PASSTHRU, Z_ARRVAL_PP(rval), elements, 0)) {
  760. return 0;
  761. }
  762. return finish_nested_data(UNSERIALIZE_PASSTHRU);
  763. }
  764. yy39:
  765. yych = *++YYCURSOR;
  766. if (yych == '+') goto yy40;
  767. if (yych <= '/') goto yy18;
  768. if (yych <= '9') goto yy41;
  769. goto yy18;
  770. yy40:
  771. yych = *++YYCURSOR;
  772. if (yych <= '/') goto yy18;
  773. if (yych >= ':') goto yy18;
  774. yy41:
  775. ++YYCURSOR;
  776. if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
  777. yych = *YYCURSOR;
  778. if (yych <= '/') goto yy18;
  779. if (yych <= '9') goto yy41;
  780. if (yych >= ';') goto yy18;
  781. yych = *++YYCURSOR;
  782. if (yych != '"') goto yy18;
  783. ++YYCURSOR;
  784. {
  785. size_t len, maxlen;
  786. char *str;
  787. len = parse_uiv(start + 2);
  788. maxlen = max - YYCURSOR;
  789. if (maxlen < len) {
  790. *p = start + 2;
  791. return 0;
  792. }
  793. if ((str = unserialize_str(&YYCURSOR, &len, maxlen)) == NULL) {
  794. return 0;
  795. }
  796. if (*(YYCURSOR) != '"') {
  797. efree(str);
  798. *p = YYCURSOR;
  799. return 0;
  800. }
  801. if (*(YYCURSOR + 1) != ';') {
  802. efree(str);
  803. *p = YYCURSOR + 1;
  804. return 0;
  805. }
  806. YYCURSOR += 2;
  807. *p = YYCURSOR;
  808. INIT_PZVAL(*rval);
  809. ZVAL_STRINGL(*rval, str, len, 0);
  810. return 1;
  811. }
  812. yy46:
  813. yych = *++YYCURSOR;
  814. if (yych == '+') goto yy47;
  815. if (yych <= '/') goto yy18;
  816. if (yych <= '9') goto yy48;
  817. goto yy18;
  818. yy47:
  819. yych = *++YYCURSOR;
  820. if (yych <= '/') goto yy18;
  821. if (yych >= ':') goto yy18;
  822. yy48:
  823. ++YYCURSOR;
  824. if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
  825. yych = *YYCURSOR;
  826. if (yych <= '/') goto yy18;
  827. if (yych <= '9') goto yy48;
  828. if (yych >= ';') goto yy18;
  829. yych = *++YYCURSOR;
  830. if (yych != '"') goto yy18;
  831. ++YYCURSOR;
  832. {
  833. size_t len, maxlen;
  834. char *str;
  835. len = parse_uiv(start + 2);
  836. maxlen = max - YYCURSOR;
  837. if (maxlen < len) {
  838. *p = start + 2;
  839. return 0;
  840. }
  841. str = (char*)YYCURSOR;
  842. YYCURSOR += len;
  843. if (*(YYCURSOR) != '"') {
  844. *p = YYCURSOR;
  845. return 0;
  846. }
  847. if (*(YYCURSOR + 1) != ';') {
  848. *p = YYCURSOR + 1;
  849. return 0;
  850. }
  851. YYCURSOR += 2;
  852. *p = YYCURSOR;
  853. INIT_PZVAL(*rval);
  854. ZVAL_STRINGL(*rval, str, len, 1);
  855. return 1;
  856. }
  857. yy53:
  858. yych = *++YYCURSOR;
  859. if (yych <= '/') {
  860. if (yych <= ',') {
  861. if (yych == '+') goto yy57;
  862. goto yy18;
  863. } else {
  864. if (yych <= '-') goto yy55;
  865. if (yych <= '.') goto yy60;
  866. goto yy18;
  867. }
  868. } else {
  869. if (yych <= 'I') {
  870. if (yych <= '9') goto yy58;
  871. if (yych <= 'H') goto yy18;
  872. goto yy56;
  873. } else {
  874. if (yych != 'N') goto yy18;
  875. }
  876. }
  877. yych = *++YYCURSOR;
  878. if (yych == 'A') goto yy76;
  879. goto yy18;
  880. yy55:
  881. yych = *++YYCURSOR;
  882. if (yych <= '/') {
  883. if (yych == '.') goto yy60;
  884. goto yy18;
  885. } else {
  886. if (yych <= '9') goto yy58;
  887. if (yych != 'I') goto yy18;
  888. }
  889. yy56:
  890. yych = *++YYCURSOR;
  891. if (yych == 'N') goto yy72;
  892. goto yy18;
  893. yy57:
  894. yych = *++YYCURSOR;
  895. if (yych == '.') goto yy60;
  896. if (yych <= '/') goto yy18;
  897. if (yych >= ':') goto yy18;
  898. yy58:
  899. ++YYCURSOR;
  900. if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
  901. yych = *YYCURSOR;
  902. if (yych <= ':') {
  903. if (yych <= '.') {
  904. if (yych <= '-') goto yy18;
  905. goto yy70;
  906. } else {
  907. if (yych <= '/') goto yy18;
  908. if (yych <= '9') goto yy58;
  909. goto yy18;
  910. }
  911. } else {
  912. if (yych <= 'E') {
  913. if (yych <= ';') goto yy63;
  914. if (yych <= 'D') goto yy18;
  915. goto yy65;
  916. } else {
  917. if (yych == 'e') goto yy65;
  918. goto yy18;
  919. }
  920. }
  921. yy60:
  922. yych = *++YYCURSOR;
  923. if (yych <= '/') goto yy18;
  924. if (yych >= ':') goto yy18;
  925. yy61:
  926. ++YYCURSOR;
  927. if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
  928. yych = *YYCURSOR;
  929. if (yych <= ';') {
  930. if (yych <= '/') goto yy18;
  931. if (yych <= '9') goto yy61;
  932. if (yych <= ':') goto yy18;
  933. } else {
  934. if (yych <= 'E') {
  935. if (yych <= 'D') goto yy18;
  936. goto yy65;
  937. } else {
  938. if (yych == 'e') goto yy65;
  939. goto yy18;
  940. }
  941. }
  942. yy63:
  943. ++YYCURSOR;
  944. {
  945. #if SIZEOF_LONG == 4
  946. use_double:
  947. #endif
  948. *p = YYCURSOR;
  949. INIT_PZVAL(*rval);
  950. ZVAL_DOUBLE(*rval, zend_strtod((const char *)start + 2, NULL));
  951. return 1;
  952. }
  953. yy65:
  954. yych = *++YYCURSOR;
  955. if (yych <= ',') {
  956. if (yych != '+') goto yy18;
  957. } else {
  958. if (yych <= '-') goto yy66;
  959. if (yych <= '/') goto yy18;
  960. if (yych <= '9') goto yy67;
  961. goto yy18;
  962. }
  963. yy66:
  964. yych = *++YYCURSOR;
  965. if (yych <= ',') {
  966. if (yych == '+') goto yy69;
  967. goto yy18;
  968. } else {
  969. if (yych <= '-') goto yy69;
  970. if (yych <= '/') goto yy18;
  971. if (yych >= ':') goto yy18;
  972. }
  973. yy67:
  974. ++YYCURSOR;
  975. if (YYLIMIT <= YYCURSOR) YYFILL(1);
  976. yych = *YYCURSOR;
  977. if (yych <= '/') goto yy18;
  978. if (yych <= '9') goto yy67;
  979. if (yych == ';') goto yy63;
  980. goto yy18;
  981. yy69:
  982. yych = *++YYCURSOR;
  983. if (yych <= '/') goto yy18;
  984. if (yych <= '9') goto yy67;
  985. goto yy18;
  986. yy70:
  987. ++YYCURSOR;
  988. if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
  989. yych = *YYCURSOR;
  990. if (yych <= ';') {
  991. if (yych <= '/') goto yy18;
  992. if (yych <= '9') goto yy70;
  993. if (yych <= ':') goto yy18;
  994. goto yy63;
  995. } else {
  996. if (yych <= 'E') {
  997. if (yych <= 'D') goto yy18;
  998. goto yy65;
  999. } else {
  1000. if (yych == 'e') goto yy65;
  1001. goto yy18;
  1002. }
  1003. }
  1004. yy72:
  1005. yych = *++YYCURSOR;
  1006. if (yych != 'F') goto yy18;
  1007. yy73:
  1008. yych = *++YYCURSOR;
  1009. if (yych != ';') goto yy18;
  1010. ++YYCURSOR;
  1011. {
  1012. *p = YYCURSOR;
  1013. INIT_PZVAL(*rval);
  1014. if (!strncmp(start + 2, "NAN", 3)) {
  1015. ZVAL_DOUBLE(*rval, php_get_nan());
  1016. } else if (!strncmp(start + 2, "INF", 3)) {
  1017. ZVAL_DOUBLE(*rval, php_get_inf());
  1018. } else if (!strncmp(start + 2, "-INF", 4)) {
  1019. ZVAL_DOUBLE(*rval, -php_get_inf());
  1020. }
  1021. return 1;
  1022. }
  1023. yy76:
  1024. yych = *++YYCURSOR;
  1025. if (yych == 'N') goto yy73;
  1026. goto yy18;
  1027. yy77:
  1028. yych = *++YYCURSOR;
  1029. if (yych <= ',') {
  1030. if (yych != '+') goto yy18;
  1031. } else {
  1032. if (yych <= '-') goto yy78;
  1033. if (yych <= '/') goto yy18;
  1034. if (yych <= '9') goto yy79;
  1035. goto yy18;
  1036. }
  1037. yy78:
  1038. yych = *++YYCURSOR;
  1039. if (yych <= '/') goto yy18;
  1040. if (yych >= ':') goto yy18;
  1041. yy79:
  1042. ++YYCURSOR;
  1043. if (YYLIMIT <= YYCURSOR) YYFILL(1);
  1044. yych = *YYCURSOR;
  1045. if (yych <= '/') goto yy18;
  1046. if (yych <= '9') goto yy79;
  1047. if (yych != ';') goto yy18;
  1048. ++YYCURSOR;
  1049. {
  1050. #if SIZEOF_LONG == 4
  1051. int digits = YYCURSOR - start - 3;
  1052. if (start[2] == '-' || start[2] == '+') {
  1053. digits--;
  1054. }
  1055. /* Use double for large long values that were serialized on a 64-bit system */
  1056. if (digits >= MAX_LENGTH_OF_LONG - 1) {
  1057. if (digits == MAX_LENGTH_OF_LONG - 1) {
  1058. int cmp = strncmp(YYCURSOR - MAX_LENGTH_OF_LONG, long_min_digits, MAX_LENGTH_OF_LONG - 1);
  1059. if (!(cmp < 0 || (cmp == 0 && start[2] == '-'))) {
  1060. goto use_double;
  1061. }
  1062. } else {
  1063. goto use_double;
  1064. }
  1065. }
  1066. #endif
  1067. *p = YYCURSOR;
  1068. INIT_PZVAL(*rval);
  1069. ZVAL_LONG(*rval, parse_iv(start + 2));
  1070. return 1;
  1071. }
  1072. yy83:
  1073. yych = *++YYCURSOR;
  1074. if (yych <= '/') goto yy18;
  1075. if (yych >= '2') goto yy18;
  1076. yych = *++YYCURSOR;
  1077. if (yych != ';') goto yy18;
  1078. ++YYCURSOR;
  1079. {
  1080. *p = YYCURSOR;
  1081. INIT_PZVAL(*rval);
  1082. ZVAL_BOOL(*rval, parse_iv(start + 2));
  1083. return 1;
  1084. }
  1085. yy87:
  1086. ++YYCURSOR;
  1087. {
  1088. *p = YYCURSOR;
  1089. INIT_PZVAL(*rval);
  1090. ZVAL_NULL(*rval);
  1091. return 1;
  1092. }
  1093. yy89:
  1094. yych = *++YYCURSOR;
  1095. if (yych <= ',') {
  1096. if (yych != '+') goto yy18;
  1097. } else {
  1098. if (yych <= '-') goto yy90;
  1099. if (yych <= '/') goto yy18;
  1100. if (yych <= '9') goto yy91;
  1101. goto yy18;
  1102. }
  1103. yy90:
  1104. yych = *++YYCURSOR;
  1105. if (yych <= '/') goto yy18;
  1106. if (yych >= ':') goto yy18;
  1107. yy91:
  1108. ++YYCURSOR;
  1109. if (YYLIMIT <= YYCURSOR) YYFILL(1);
  1110. yych = *YYCURSOR;
  1111. if (yych <= '/') goto yy18;
  1112. if (yych <= '9') goto yy91;
  1113. if (yych != ';') goto yy18;
  1114. ++YYCURSOR;
  1115. {
  1116. long id;
  1117. *p = YYCURSOR;
  1118. if (!var_hash) return 0;
  1119. id = parse_iv(start + 2) - 1;
  1120. if (id == -1 || var_access(var_hash, id, &rval_ref) != SUCCESS) {
  1121. return 0;
  1122. }
  1123. if (*rval == *rval_ref) return 0;
  1124. if (*rval != NULL) {
  1125. var_push_dtor_no_addref(var_hash, rval);
  1126. }
  1127. *rval = *rval_ref;
  1128. Z_ADDREF_PP(rval);
  1129. Z_UNSET_ISREF_PP(rval);
  1130. return 1;
  1131. }
  1132. yy95:
  1133. yych = *++YYCURSOR;
  1134. if (yych <= ',') {
  1135. if (yych != '+') goto yy18;
  1136. } else {
  1137. if (yych <= '-') goto yy96;
  1138. if (yych <= '/') goto yy18;
  1139. if (yych <= '9') goto yy97;
  1140. goto yy18;
  1141. }
  1142. yy96:
  1143. yych = *++YYCURSOR;
  1144. if (yych <= '/') goto yy18;
  1145. if (yych >= ':') goto yy18;
  1146. yy97:
  1147. ++YYCURSOR;
  1148. if (YYLIMIT <= YYCURSOR) YYFILL(1);
  1149. yych = *YYCURSOR;
  1150. if (yych <= '/') goto yy18;
  1151. if (yych <= '9') goto yy97;
  1152. if (yych != ';') goto yy18;
  1153. ++YYCURSOR;
  1154. {
  1155. long id;
  1156. *p = YYCURSOR;
  1157. if (!var_hash) return 0;
  1158. id = parse_iv(start + 2) - 1;
  1159. if (id == -1 || var_access(var_hash, id, &rval_ref) != SUCCESS) {
  1160. return 0;
  1161. }
  1162. if (*rval != NULL) {
  1163. var_push_dtor_no_addref(var_hash, rval);
  1164. }
  1165. *rval = *rval_ref;
  1166. Z_ADDREF_PP(rval);
  1167. Z_SET_ISREF_PP(rval);
  1168. return 1;
  1169. }
  1170. }
  1171. return 0;
  1172. }