The condition, NET_HEADSPACE(&(Nbuf->BlockOp[Index])) < Len, is meaningless if Index = 0. So checking 'Index != 0' should be performed first in the if statement. Cc: Maciej Rabeda Cc: Siyuan Fu Cc: Jiaxin Wu Signed-off-by: Shenglei Zhang --- NetworkPkg/Library/DxeNetLib/NetBuffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NetworkPkg/Library/DxeNetLib/NetBuffer.c b/NetworkPkg/Library/DxeNetLib/NetBuffer.c index a232802c9a21..77634dabf912 100644 --- a/NetworkPkg/Library/DxeNetLib/NetBuffer.c +++ b/NetworkPkg/Library/DxeNetLib/NetBuffer.c @@ -1063,7 +1063,7 @@ NetbufAllocSpace ( } else { NetbufGetByte (Nbuf, 0, &Index); - if ((NET_HEADSPACE(&(Nbuf->BlockOp[Index])) < Len) && (Index > 0)) { + if ((Index > 0) && (NET_HEADSPACE(&(Nbuf->BlockOp[Index])) < Len)) { Index--; } } -- 2.18.0.windows.1