@@ -378,7 +378,7 @@ private int ListObjectKeys(RespCommand command)
378378 RespCommand . LINSERT => SingleKey ( StoreType . Object , LockType . Exclusive ) ,
379379 RespCommand . LLEN => SingleKey ( StoreType . Object , LockType . Shared ) ,
380380 RespCommand . LMOVE => ListKeys ( 2 , StoreType . Object , LockType . Exclusive ) ,
381- RespCommand . LMPOP => ListReadKeysWithCount ( LockType . Exclusive ) ,
381+ RespCommand . LMPOP => ListReadKeysWithCount ( LockType . Exclusive , mandatoryArgs : 1 ) ,
382382 RespCommand . LPOP => SingleKey ( StoreType . Object , LockType . Exclusive ) ,
383383 RespCommand . LPOS => SingleKey ( StoreType . Object , LockType . Shared ) ,
384384 RespCommand . LPUSH => SingleKey ( StoreType . Object , LockType . Exclusive ) ,
@@ -487,17 +487,20 @@ private int ListKeys(int inputCount, StoreType storeType, LockType type)
487487 /// <summary>
488488 /// Returns a list of keys for LMPOP command
489489 /// </summary>
490- private int ListReadKeysWithCount ( LockType type , bool isObject = true )
490+ private int ListReadKeysWithCount ( LockType type , bool isObject = true , int mandatoryArgs = 0 )
491491 {
492- var numKeysArg = respSession . GetCommandAsArgSlice ( out var success ) ;
493- if ( ! success ) return - 2 ;
492+ if ( respSession . parseState . Count == 0 )
493+ return - 2 ;
494494
495- if ( ! NumUtils . TryParse ( numKeysArg . ReadOnlySpan , out int numKeys ) ) return - 2 ;
495+ if ( ! respSession . parseState . TryGetInt ( 0 , out var numKeys ) )
496+ return - 2 ;
496497
497- for ( var i = 0 ; i < numKeys ; i ++ )
498+ if ( numKeys + mandatoryArgs + 1 > respSession . parseState . Count )
499+ return - 2 ;
500+
501+ for ( var i = 1 ; i < numKeys + 1 ; i ++ )
498502 {
499- var key = respSession . GetCommandAsArgSlice ( out success ) ;
500- if ( ! success ) return - 2 ;
503+ var key = respSession . parseState . GetArgSliceByRef ( i ) ;
501504 SaveKeyEntryToLock ( key , isObject , type ) ;
502505 SaveKeyArgSlice ( key ) ;
503506 }
0 commit comments