summaryrefslogtreecommitdiff
path: root/xs.h
diff options
context:
space:
mode:
authorSaagar Jha <saagar@saagarjha.com>2023-04-10 01:29:07 -0700
committerSaagar Jha <saagar@saagarjha.com>2023-04-10 01:29:07 -0700
commit632bbe475c2d948cdae4eaba3367b9e65c5ff141 (patch)
tree96e208c55f2c768554bf4971d00b5ea718767322 /xs.h
parent74817a4552e41a34644ec869c6ff7578854fac74 (diff)
Avoid reading too much data in xs_data_new
Diffstat (limited to 'xs.h')
-rw-r--r--xs.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/xs.h b/xs.h
index 2fc7dda..fef91b7 100644
--- a/xs.h
+++ b/xs.h
@@ -1057,12 +1057,12 @@ xs_data *xs_data_new(const void *data, int size)
xs_data *v;
/* add the overhead (data type + 24bit size) */
- size += 4;
+ int total_size = size + 4;
- v = xs_realloc(NULL, _xs_blk_size(size));
+ v = xs_realloc(NULL, _xs_blk_size(total_size));
v[0] = XSTYPE_DATA;
- _xs_put_24b(v + 1, size);
+ _xs_put_24b(v + 1, total_size);
memcpy(&v[4], data, size);