commit 632bbe4
Saagar Jha
·
2023-04-10 08:29:07 +0000 UTC
parent 74817a4
Avoid reading too much data in xs_data_new
1 files changed,
+3,
-3
M
xs.h
M
xs.h
+3,
-3
1@@ -1057,12 +1057,12 @@ xs_data *xs_data_new(const void *data, int size)
2 xs_data *v;
3
4 /* add the overhead (data type + 24bit size) */
5- size += 4;
6+ int total_size = size + 4;
7
8- v = xs_realloc(NULL, _xs_blk_size(size));
9+ v = xs_realloc(NULL, _xs_blk_size(total_size));
10 v[0] = XSTYPE_DATA;
11
12- _xs_put_24b(v + 1, size);
13+ _xs_put_24b(v + 1, total_size);
14
15 memcpy(&v[4], data, size);
16