Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

“NullPointerException”The number passed in the api is zzRefill is a null pointer. #2769

Open
Cici-Musse-Lee opened this issue May 16, 2022 · 0 comments

Comments

@Cici-Musse-Lee
Copy link

Cici-Musse-Lee commented May 16, 2022

The file path is org.zkoss.json.parser.Yylex.
In our test case, pass reader1=null into the function whose api is JSONParser0.parse(). Inside this api, the zzRefill function in Yylen will be called and a null pointer exception will be generated when it is called.
source code:

private boolean zzRefill() throws java.io.IOException{
        /*first:make room (if you can)*/
        if(zzStartRead>0){
        System.arraycopy(zzBuffer,zzStartRead,
                                      zzBuffer,0,
                                      zzEndRead-zzStartRead);

            /*translate stored positions */
             zzEndRead-=zzStartRead;
             zzCurrentPos-=zzStartRead;
             zzMarkedPos-=zzStartRead;
             zzStartRead = 0;
    }

        /*is the buffer big enough?*/
        if (zzCurrentPos >zzBuffer.length){
             /*if not:blow it up */
             char newBuffer[]=new char[zzCurrentPos*2];
             System.arraycopy(zzBuffer,0,newBuffer,0,zzBuffer.length);
             zzBuffer = newBuffer;
     }
        /*finally:fill the buffer with new input */
        int numRead zzReader.read (zzBuffer,zzEndRead,zzBuffer.length-zzEndRead);

        if (numRead > 0){
             zzEndRead+=numRead;
             return false;
     }
}

test code:

    public void test_parse 3_18()throws java.io.IOException,org.zkoss.json.parser.ParseException,NoSuchField

        java.io.Reader reader1 = null;
        org.zkoss.json.parser.JSONParser JSONParser0 = new org.zkoss.]son.parser.JSONParser();
        JSONParser0.parse(reader1);
@Cici-Musse-Lee Cici-Musse-Lee changed the title Found 2 JDK errors during testing ZK Found 2 JDK and 11 zcommon.jar errors during testing, involving CheckedInputStream and ObjectOutputStream, and several ZK bugs May 16, 2022
@Cici-Musse-Lee Cici-Musse-Lee changed the title Found 2 JDK and 11 zcommon.jar errors during testing, involving CheckedInputStream and ObjectOutputStream, and several ZK bugs Found 2 JDK and 11 zcommon.jar errors during testing May 16, 2022
@Cici-Musse-Lee Cici-Musse-Lee changed the title Found 2 JDK and 11 zcommon.jar errors during testing “NullPointerException”The number passed in the api is zz is a null pointer. May 24, 2022
@Cici-Musse-Lee Cici-Musse-Lee changed the title “NullPointerException”The number passed in the api is zz is a null pointer. “NullPointerException”The number passed in the api is zzRefill is a null pointer. May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant