aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_tensor.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-08-25 15:41:46 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-08-25 15:42:12 +0100
commit8a2cad181848bc7825001bb1a418aa1982c566ab (patch)
treed690596a9cc840e8b27f0480554538965745cfda /src/lua/lua_tensor.c
parentf5a453a97f446996a91e793c54c6144cfbc15522 (diff)
downloadrspamd-8a2cad181848bc7825001bb1a418aa1982c566ab.tar.gz
rspamd-8a2cad181848bc7825001bb1a418aa1982c566ab.zip
[Minor] Lua_tensor: Fix newindex row assignment
Diffstat (limited to 'src/lua/lua_tensor.c')
-rw-r--r--src/lua/lua_tensor.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lua/lua_tensor.c b/src/lua/lua_tensor.c
index 09a10cabc..f8386d6f3 100644
--- a/src/lua/lua_tensor.c
+++ b/src/lua/lua_tensor.c
@@ -383,7 +383,7 @@ lua_tensor_newindex (lua_State *L)
if (t->ndims == 1) {
/* Individual element */
- if (idx <= t->dim[0]) {
+ if (idx <= t->dim[0] && idx > 0) {
rspamd_tensor_num_t value = lua_tonumber (L, 3), old;
old = t->data[idx - 1];
@@ -405,8 +405,9 @@ lua_tensor_newindex (lua_State *L)
if (row) {
if (row->ndims == 1) {
if (row->dim[0] == t->dim[1]) {
- if (idx <= t->dim[0]) {
- memcpy (&t->data[idx * t->dim[0]],
+ if (idx > 0 && idx <= t->dim[0]) {
+ idx --; /* Zero based index */
+ memcpy (&t->data[idx * t->dim[1]],
row->data,
t->dim[1] * sizeof (rspamd_tensor_num_t));