↑ | 1-62
-- | --
63 | // JsGetCurrentContext(&ctx);
64 | void *voidPtr;
65 | JsGetContextData(ctx, &voidPtr);
| The status of this call to externally defined (SAL) JsGetContextData is not checked, potentially leaving voidPtr uninitialized.
66 |
67 | auto *f = static_cast(voidPtr);
↓↑ | 68-73
74 |
75 | JsValueRef value;
76 | JsCreateExternalObject(functionPtr, nullptr /*JsFinalizeCallback*/, &value);
| The status of this call to externally defined (SAL) JsCreateExternalObject is not checked, potentially leaving value uninitialized.
77 |
78 | auto functionObject = ChakraObject(value);
↓↑ | 79-137
138 | auto jsName = ChakraString(name);
139 | JsValueRef functionObj;
140 | JsCreateNamedFunction(jsName, callback, nullptr /*callbackstate*/, &functionObj);
| The status of this call to externally defined (SAL) JsCreateNamedFunction is not checked, potentially leaving functionObj uninitialized.
141 | return functionObj;
142 | }
↓↑ | 143-144
145 | ChakraString jsName(name);
146 | JsValueRef functionObj;
147 | JsCreateNamedFunction(jsName, callback, nullptr /*callbackstate*/, &functionObj);
| The status of this call to externally defined (SAL) JsCreateNamedFunction is not checked, potentially leaving functionObj uninitialized.
148 | ChakraObject::getGlobalObject().setProperty(jsName, ChakraValue(functionObj));
149 | }
↓↑ | 150-164
165 | const wchar_t *scriptRaw;
166 | size_t scriptRawLength;
167 | JsStringToPointer(script, &scriptRaw, &scriptRawLength);
| The status of this call to externally defined (SAL) JsStringToPointer is not checked, potentially leaving scriptRaw uninitialized.
168 |
169 | const wchar_t *sourceRaw;
170 | size_t sourceRawLength;
171 | JsStringToPointer(source, &sourceRaw, &sourceRawLength);
| The status of this call to externally defined (SAL) JsStringToPointer is not checked, potentially leaving sourceRaw uninitialized.
172 |
173 | auto result = JsRunScript(scriptRaw, JS_SOURCE_CONTEXT_NONE /*sourceContext*/, sourceRaw, &value);
↓↑ | 174-272
273 | JsValueRef GetJSONObject() {
274 | JsValueRef globalObject;
275 | JsGetGlobalObject(&globalObject);
| The status of this call to externally defined (SAL) JsGetGlobalObject is not checked, potentially leaving globalObject uninitialized.
276 |
277 | JsPropertyIdRef propertyId;
↓↑ | 278-287
288 | int StringGetLength(_In_ JsValueRef string) {
289 | int length;
290 | JsGetStringLength(string, &length);
| The status of this call to externally defined (SAL) JsGetStringLength is not checked, potentially leaving length uninitialized.
291 | return length;
292 | }
↓↑ | 293-320
321 | if (StringGetLength(string) == 0) {
322 | JsValueRef value;
323 | JsGetNullValue(&value);
| The status of this call to externally defined (SAL) JsGetNullValue is not checked, potentially leaving value uninitialized.
324 | return value;
325 | }
↓↑ | 326-380
381 | JsValueRef JSObjectGetPropertyAtIndex(JsValueRef object, unsigned propertyIndex, JsValueRef *exception) {
382 | JsValueRef index;
383 | JsIntToNumber(propertyIndex, &index);
| The status of this call to externally defined (SAL) JsIntToNumber is not checked, potentially leaving index uninitialized.
384 | JsValueRef property;
385 | auto result = JsGetIndexedProperty(object, index, &property);
↓↑ | 386-418
419 | JsValueRef JSObjectCopyPropertyNames(JsValueRef object) {
420 | JsValueRef propertyNamesArrayRef;
421 | JsGetOwnPropertyNames(object, &propertyNamesArrayRef);
| The status of this call to externally defined (SAL) JsGetOwnPropertyNames is not checked, potentially leaving propertyNamesArrayRef uninitialized.
422 | return propertyNamesArrayRef;
423 | }
↓↑ | 424-424
425 | unsigned JSPropertyNameArrayGetCount(JsValueRef namesRef) {
426 | JsPropertyIdRef propertyId;
427 | JsGetPropertyIdFromName(L"length", &propertyId);
| The status of this call to externally defined (SAL) JsGetPropertyIdFromName is not checked, potentially leaving propertyId uninitialized.
428 | JsValueRef countRef;
429 | JsGetProperty(namesRef, propertyId, &countRef);
| The status of this call to externally defined (SAL) JsGetProperty is not checked, potentially leaving countRef uninitialized.
430 | int count;
431 | JsNumberToInt(countRef, &count);
| The status of this call to externally defined (SAL) JsNumberToInt is not checked, potentially leaving count uninitialized.
432 | return count;
433 | }
↓↑ | 434-434
435 | JsValueRef JSPropertyNameArrayGetNameAtIndex(JsValueRef namesRef, unsigned idx) {
436 | JsValueRef index;
437 | JsIntToNumber(idx, &index);
| The status of this call to externally defined (SAL) JsIntToNumber is not checked, potentially leaving index uninitialized.
438 | JsValueRef propertyName;
439 | JsGetIndexedProperty(namesRef, index, &propertyName);
| The status of this call to externally defined (SAL) JsGetIndexedProperty is not checked, potentially leaving propertyName uninitialized.
440 | return propertyName;
441 | }
↓ | 442-468
↑ | 1-58
-- | --
59 | size_t length() const {
60 | int length;
61 | JsGetStringLength(m_string, &length);
| The status of this call to externally defined (SAL) JsGetStringLength is not checked, potentially leaving length uninitialized.
62 | return length;
63 | }
↓↑ | 64-150
151 | bool isFunction() const {
152 | JsValueType type;
153 | JsGetValueType(m_obj, &type);
| The status of this call to externally defined (SAL) JsGetValueType is not checked, potentially leaving type uninitialized.
154 | return type == JsFunction;
155 | }
↓↑ | 156-209
210 | JsValueType getType() const {
211 | JsValueType type;
212 | JsGetValueType(m_value, &type);
| The status of this call to externally defined (SAL) JsGetValueType is not checked, potentially leaving type uninitialized.
213 | return type;
214 | }
↓↑ | 215-219
220 | bool asBoolean() const {
221 | bool value;
222 | JsBooleanToBool(m_value, &value);
| The status of this call to externally defined (SAL) JsBooleanToBool is not checked, potentially leaving value uninitialized.
223 | return value;
224 | }
↓↑ | 225-284
285 | static ChakraValue makeNumber(double dbl) {
286 | JsValueRef value;
287 | JsDoubleToNumber(dbl, &value);
| The status of this call to externally defined (SAL) JsDoubleToNumber is not checked, potentially leaving value uninitialized.
288 | return value;
289 | }
↓↑ | 290-290
291 | static ChakraValue makeUndefined() {
292 | JsValueRef value;
293 | JsGetUndefinedValue(&value);
| The status of this call to externally defined (SAL) JsGetUndefinedValue is not checked, potentially leaving value uninitialized.
294 | return value;
295 | }
↓ | 296-308
Problem Description
CodeQL reports 22
Conditionally uninitialized variable
warnings across the ChakraHelpers.cpp and ChakraValue.h files.Steps To Reproduce
Link to CodeQL (corpnet-only): https://onees.lgtm.microsoft.com/projects/u/gh/microsoft%2Freact-native-windows%2Ftree%2Fmain/alerts/?mode=tree&ruleFocus=1000886
Expected Results
No response
CLI version
npx react-native --version
Environment
Target Platform Version
No response
Target Device(s)
No response
Visual Studio Version
Visual Studio 2019
Build Configuration
No response
Snack, code example, screenshot, or link to a repository