Skip to content

Commit 0a42832

Browse files
committed
Make marshal.loads not crash on empty input
1 parent bb2a6bc commit 0a42832

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MarshalModuleBuiltins.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
*/
2626
package com.oracle.graal.python.builtins.modules;
2727

28+
import static com.oracle.graal.python.builtins.PythonBuiltinClassType.EOFError;
2829
import static com.oracle.graal.python.runtime.exception.PythonErrorType.NotImplementedError;
2930
import static com.oracle.graal.python.runtime.exception.PythonErrorType.ValueError;
3031

@@ -565,7 +566,11 @@ public void reset() {
565566
}
566567

567568
private int readByte() {
568-
return data[index++];
569+
if (index < data.length) {
570+
return data[index++];
571+
} else {
572+
throw raise(EOFError, "EOF read where not expected");
573+
}
569574
}
570575

571576
private int readInt() {

0 commit comments

Comments
 (0)