1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-18 09:13:14 +00:00

Fixed bug, where if Duktape_GetContextGuidHex() returned non-NULL, an attempt to modify immutable memory was attempted

This commit is contained in:
Bryan Roe
2019-01-23 11:37:42 -08:00
parent 3b514cd526
commit 3a0f519f54

View File

@@ -167,8 +167,11 @@ duk_ret_t ILibDuktape_SimpleDataStore_Keys(duk_context *ctx)
if (enumerator.GuidHex != NULL) if (enumerator.GuidHex != NULL)
{ {
enumerator.GuidHexLen = 1 + (int)strnlen_s(enumerator.GuidHex, sizeof(ILibScratchPad)); enumerator.GuidHexLen = 1 + (int)strnlen_s(enumerator.GuidHex, sizeof(ILibScratchPad));
enumerator.GuidHex[enumerator.GuidHexLen - 1] = '/'; char *tmp = Duktape_PushBuffer(ctx, enumerator.GuidHexLen + 1);
enumerator.GuidHex[enumerator.GuidHexLen] = 0; memcpy_s(tmp, ILibMemory_Size(tmp), enumerator.GuidHex, enumerator.GuidHexLen - 1);
tmp[enumerator.GuidHexLen - 1] = '/';
tmp[enumerator.GuidHexLen] = 0;
enumerator.GuidHex = tmp;
} }
duk_push_array(ctx); // [DataStore][ptr][retVal] duk_push_array(ctx); // [DataStore][ptr][retVal]