Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 38023f0

Browse files
James Prestwoodgrgustaf
authored andcommitted
[ocf/promises] Fixed OCF crash because of bug from promise patch (#798)
- Fixed OCF on linux by updating iotivity-constrained (client + server compiled in previously did not work) Signed-off-by: James Prestwood <[email protected]>
1 parent b29dbbc commit 38023f0

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

deps/iotivity-constrained

Submodule iotivity-constrained updated from 057b083 to 12f1090

src/zjs_promise.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ void zjs_make_promise(jerry_value_t obj, zjs_post_promise_func post,
9898

9999
new->then_id = zjs_add_callback_once(ZJS_UNDEFINED,
100100
obj,
101-
handle,
101+
new,
102102
post_promise);
103103

104104
new->catch_id = zjs_add_callback_once(ZJS_UNDEFINED,
105105
obj,
106-
handle,
106+
new,
107107
post_promise);
108108

109109
// Add the "promise" object to the object passed as a property, because the

src/zjs_test_promise.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,35 @@
77
#include "zjs_promise.h"
88
#include "zjs_util.h"
99

10+
typedef struct dummy_handle {
11+
uint32_t value;
12+
} dummy_handle_t;
13+
14+
#define TEST_VAL 42
15+
16+
static void post_promise(void* handle)
17+
{
18+
if (handle) {
19+
dummy_handle_t* h = (dummy_handle_t*)handle;
20+
if (h->value != TEST_VAL) {
21+
ERR_PRINT("Handle was not valid!!!\n");
22+
}
23+
zjs_free(h);
24+
}
25+
}
26+
1027
static jerry_value_t create_promise(const jerry_value_t function_obj,
1128
const jerry_value_t this,
1229
const jerry_value_t argv[],
1330
const jerry_length_t argc)
1431
{
32+
dummy_handle_t* handle = zjs_malloc(sizeof(dummy_handle_t));
33+
handle->value = TEST_VAL;
34+
1535
jerry_value_t promise = jerry_create_object();
1636
ZJS_PRINT("Testing promise, object = %u\n", promise);
1737

18-
zjs_make_promise(promise, NULL, NULL);
38+
zjs_make_promise(promise, post_promise, handle);
1939

2040
return promise;
2141
}

0 commit comments

Comments
 (0)