@@ -2111,8 +2111,7 @@ static CommandResult createReply(Packet packet, DebuggerController controller) {
2111
2111
}
2112
2112
2113
2113
int startFrame = input .readInt ();
2114
- int length = input .readInt ();
2115
- final int requestedLength = length ;
2114
+ int requestedLength = input .readInt ();
2116
2115
2117
2116
controller .fine (() -> "requesting frames for thread: " + controller .getContext ().getThreadName (thread ));
2118
2117
controller .fine (() -> "startFrame requested: " + startFrame );
@@ -2127,13 +2126,21 @@ static CommandResult createReply(Packet packet, DebuggerController controller) {
2127
2126
}
2128
2127
2129
2128
CallFrame [] frames = suspendedInfo .getStackFrames ();
2130
-
2131
- if (length == -1 || length > frames .length ) {
2132
- length = frames .length ;
2129
+ if (startFrame < 0 || startFrame >= frames .length ) {
2130
+ reply .errorCode (ErrorCodes .INVALID_INDEX );
2131
+ return new CommandResult (reply );
2132
+ }
2133
+ int length ;
2134
+ if (requestedLength == -1 ) {
2135
+ length = frames .length - startFrame ;
2136
+ } else if (requestedLength < 0 || startFrame + requestedLength > frames .length ) {
2137
+ reply .errorCode (ErrorCodes .INVALID_LENGTH );
2138
+ return new CommandResult (reply );
2139
+ } else {
2140
+ length = requestedLength ;
2133
2141
}
2134
2142
reply .writeInt (length );
2135
- final int finalLength = length ;
2136
- controller .fine (() -> "returning " + finalLength + " frames for thread: " + controller .getContext ().getThreadName (thread ));
2143
+ controller .fine (() -> "returning " + length + " frames for thread: " + controller .getContext ().getThreadName (thread ));
2137
2144
2138
2145
for (int i = startFrame ; i < startFrame + length ; i ++) {
2139
2146
CallFrame frame = frames [i ];
0 commit comments