edje lua2: check string ptr before dereference

Summary: fix null pointer dereference

Reviewers: Hermet, kimcinoo, jsuya, raster

Reviewed By: kimcinoo

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D12309
This commit is contained in:
Taehyub Kim 2021-11-30 10:48:37 +09:00 committed by Shinwoo Kim
parent 38a4c53a84
commit d5c8311470
1 changed files with 8 additions and 5 deletions

View File

@ -491,12 +491,15 @@ _elua_scan_params(lua_State *L, int i, char *params, ...) // Stack usage -
size_t len;
char *temp = (char *)lua_tolstring(L, j, &len); // Stack usage [-0, +0, m]
len++; // Cater for the null at the end.
*v = malloc(len);
if (*v)
if (temp)
{
memcpy(*v, temp, len);
n++;
len++; // Cater for the null at the end.
*v = malloc(len);
if (*v)
{
memcpy(*v, temp, len);
n++;
}
}
}
break;