Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0003134 [Quercus] minor always 12-07-08 00:30 12-10-08 09:15
Reporter koreth View Status public  
Assigned To nam
Priority normal Resolution fixed  
Status closed   Product Version 3.2.1
Summary 0003134: json_decode throws exception on empty input
Description <?php
json_decode('', true);

Vanilla PHP executes this script; Quercus throws an exception:

[00:28:52.271] {http--8080-7} java.lang.ArrayIndexOutOfBoundsException
[00:28:52.271] {http--8080-7} at com.caucho.quercus.env.StringBuilderValue.<init>(StringBuilderValue.java:74)
[00:28:52.271] {http--8080-7} at com.caucho.quercus.env.StringBuilderValue.subSequence(StringBuilderValue.java:660)
[00:28:52.271] {http--8080-7} at com.caucho.quercus.env.StringValue.substring(StringValue.java:1671)
[00:28:52.271] {http--8080-7} at com.caucho.quercus.lib.json.JsonDecoder.errorReturn(JsonDecoder.java:409)
[00:28:52.271] {http--8080-7} at com.caucho.quercus.lib.json.JsonDecoder.errorReturn(JsonDecoder.java:392)
[00:28:52.271] {http--8080-7} at com.caucho.quercus.lib.json.JsonDecoder.jsonDecodeImpl(JsonDecoder.java:115)
[00:28:52.271] {http--8080-7} at com.caucho.quercus.lib.json.JsonDecoder.jsonDecode(JsonDecoder.java:54)
[00:28:52.271] {http--8080-7} at com.caucho.quercus.lib.json.JsonModule.json_decode(JsonModule.java:303)
[00:28:52.271] {http--8080-7} at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Additional Information
Attached Files

- Relationships

- Notes
(0003580)
koreth
12-07-08 09:21

This is not a robust fix, but it lets me proceed with testing my PHP code:

--- a/modules/quercus/src/com/caucho/quercus/lib/json/JsonModule.java
+++ b/modules/quercus/src/com/caucho/quercus/lib/json/JsonModule.java
@@ -300,6 +300,8 @@ public class JsonModule
                           StringValue s,
                           @Optional("false") boolean assoc)
   {
+ if (s.length() == 0)
+ return BooleanValue.FALSE;
     return (new JsonDecoder()).jsonDecode(env, s, assoc);
   }
 
(0003594)
nam
12-10-08 09:15

php/471c
 

- Issue History
Date Modified Username Field Change
12-07-08 00:30 koreth New Issue
12-07-08 09:21 koreth Note Added: 0003580
12-10-08 09:15 nam Status new => assigned
12-10-08 09:15 nam Assigned To  => nam
12-10-08 09:15 nam Status assigned => closed
12-10-08 09:15 nam Note Added: 0003594
12-10-08 09:15 nam Resolution open => fixed
12-10-08 09:15 nam Fixed in Version  => 4.0.0


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
31 total queries executed.
27 unique queries executed.
Powered by Mantis Bugtracker