4539: Fix argument order in test, use constant r=def- a=Robyt3

- Use `CVariableInt::MAX_BYTES_PACKED` in two more places.
- Fix order of arguments in a test case.

## Checklist

- [X] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [X] Considered possible null pointers and out of bounds array indexing
- [X] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Robert Müller <robert.mueller@uni-siegen.de>
This commit is contained in:
bors[bot] 2021-12-27 22:58:47 +00:00 committed by GitHub
commit 63c33d2754
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View file

@ -19,7 +19,7 @@ void CPacker::AddInt(int i)
return;
// make sure that we have space enough
if(m_pEnd - m_pCurrent < 6)
if(m_pEnd - m_pCurrent <= CVariableInt::MAX_BYTES_PACKED)
{
dbg_break();
m_Error = 1;

View file

@ -185,7 +185,7 @@ void CSnapshotDelta::UndiffItem(int *pPast, int *pDiff, int *pOut, int Size)
m_aSnapshotDataRate[m_SnapshotCurrent] += 1;
else
{
unsigned char aBuf[16];
unsigned char aBuf[CVariableInt::MAX_BYTES_PACKED];
unsigned char *pEnd = CVariableInt::Pack(aBuf, *pDiff);
m_aSnapshotDataRate[m_SnapshotCurrent] += (int)(pEnd - (unsigned char *)aBuf) * 8;
}

View file

@ -48,7 +48,7 @@ TEST(CVariableInt, RoundtripCompressDecompress)
ASSERT_EQ(DecompressedSize, sizeof(DATA));
for(int i = 0; i < NUM; i++)
{
EXPECT_EQ(DATA[i], aDecompressed[i]);
EXPECT_EQ(aDecompressed[i], DATA[i]);
}
}