Skip to content

Commit 55331ae

Browse files
committed
Fix segfault with AQ JSON payload with date and interval fields and code refactoring and formatting
1 parent aca0e87 commit 55331ae

File tree

15 files changed

+160
-366
lines changed

15 files changed

+160
-366
lines changed

binding.gyp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"src/njsTokenCallback.c",
1212
"src/njsConnection.c",
1313
"src/njsDbObject.c",
14+
"src/njsJsContext.c",
1415
"src/njsJsonBuffer.c",
1516
"src/njsLob.c",
1617
"src/njsModule.c",

doc/src/release_notes.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Common Changes
6262
Thin Mode Changes
6363
+++++++++++++++++
6464

65-
#) Added support for config-file, config-ociobject, and config-azurevault
65+
#) Added support for config-file, config-ociobject, and config-azurevault
6666
configuration providers.
6767

6868
#) Fixed bug which forced node-oracledb to resolve the database host name
@@ -105,6 +105,9 @@ Thick Mode Changes
105105
connections to Oracle Globally Distributed Databases are created with
106106
proper sharding key values.
107107

108+
#) Fixed segfault with date, timestamp and interval fields in JSON payloads,
109+
when dequeuing AQ messages.
110+
108111
#) Fixed bug resulting in a segfault when unable to load the Oracle Client
109112
libraries (`ODPI-C <https://github.com/oracle/odpi>`__ change).
110113

src/njsAqMessage.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,17 @@ NJS_NAPI_METHOD_IMPL_SYNC(njsAqMessage_getPayload, 0, NULL)
292292
const char *value;
293293
dpiJsonNode *topNode;
294294
dpiJson *json;
295+
njsJsContext jsContext;
295296

296297
if (message->isPayloadJsonType) {
297298
// JSON
298299
if (dpiMsgProps_getPayloadJson(message->handle, &json) < 0)
299300
return false;
300-
if (dpiJson_getValue(json, DPI_JSON_OPT_DATE_AS_DOUBLE, &topNode) < 0)
301+
if (dpiJson_getValue(json, DPI_JSON_OPT_DEFAULT, &topNode) < 0)
301302
return false;
302-
if (!njsBaton_getJsonNodeValue(NULL, topNode, env, returnValue))
303+
if (!njsJsContext_populate(env, globals, &jsContext))
304+
return false;
305+
if (!njsJsContext_getJsonNodeValue(&jsContext, topNode, env, returnValue))
303306
return false;
304307
} else {
305308
// DB Object

src/njsAqQueue.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ static bool njsAqQueue_createMessage(njsBaton *baton, njsAqQueue *queue,
134134
NJS_CHECK_NAPI(env, napi_get_named_property(env, value, "payload",
135135
&payloadObj))
136136
NJS_CHECK_NAPI(env, napi_instanceof(env, payloadObj,
137-
baton->jsDbObjectConstructor, &isDbObject))
137+
baton->jsContext.jsDbObjectConstructor, &isDbObject))
138138
if (isDbObject) {
139139
// DB Object
140140
if (!njsDbObject_getInstance(baton->globals, env, payloadObj, &obj))
@@ -412,7 +412,7 @@ NJS_NAPI_METHOD_IMPL_ASYNC(njsAqQueue_enq, 1, NULL)
412412
if (!baton->msgProps)
413413
return njsBaton_setErrorInsufficientMemory(baton);
414414

415-
if (!njsBaton_setJsValues(baton, env))
415+
if (!njsBaton_setJsContext(baton, env))
416416
return false;
417417
for (i = 0; i < baton->numMsgProps; i++) {
418418
NJS_CHECK_NAPI(env, napi_get_element(env, args[0], i, &message))

0 commit comments

Comments
 (0)