mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
vfs uart tests: Avoid 1 byte heap overrun & memory leak
This commit is contained in:
parent
895e7423a3
commit
3f68c5e988
@ -50,8 +50,8 @@ TEST_CASE("can read from stdin", "[vfs]")
|
|||||||
|
|
||||||
const size_t count = 12;
|
const size_t count = 12;
|
||||||
srand(count);
|
srand(count);
|
||||||
char* data = (char*) calloc(1, count * 8 + 1);
|
char* data = (char*) calloc(1, count * 8 + 2);
|
||||||
char* buf = (char*) calloc(1, count * 8 + 1);
|
char* buf = (char*) calloc(1, count * 8 + 2);
|
||||||
char* p = data;
|
char* p = data;
|
||||||
for (size_t i = 0; i < count; ++i) {
|
for (size_t i = 0; i < count; ++i) {
|
||||||
p += sprintf(p, "%08x", rand());
|
p += sprintf(p, "%08x", rand());
|
||||||
@ -62,6 +62,9 @@ TEST_CASE("can read from stdin", "[vfs]")
|
|||||||
size_t cb = fread(buf, 1, len, stdin);
|
size_t cb = fread(buf, 1, len, stdin);
|
||||||
TEST_ASSERT_EQUAL(len, cb);
|
TEST_ASSERT_EQUAL(len, cb);
|
||||||
TEST_ASSERT_EQUAL_UINT8_ARRAY(data, buf, len);
|
TEST_ASSERT_EQUAL_UINT8_ARRAY(data, buf, len);
|
||||||
|
|
||||||
|
free(data);
|
||||||
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user