exceptions generated from incorrect arg usage on JSC trace and LegacyProfile functions
Reviewed By: astreet Differential Revision: D2729015 fb-gh-sync-id: a3f56554ff6e77170e07aaf93934f93522b3a81b
This commit is contained in:
parent
5aef380609
commit
e7a4b20d75
|
@ -19,4 +19,13 @@ void installGlobalFunction(
|
||||||
JSStringRelease(jsName);
|
JSStringRelease(jsName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JSValueRef makeJSCException(
|
||||||
|
JSContextRef ctx,
|
||||||
|
const char* exception_text) {
|
||||||
|
JSStringRef message = JSStringCreateWithUTF8CString(exception_text);
|
||||||
|
JSValueRef exceptionString = JSValueMakeString(ctx, message);
|
||||||
|
JSStringRelease(message);
|
||||||
|
return JSValueToObject(ctx, exceptionString, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
} }
|
} }
|
||||||
|
|
|
@ -13,4 +13,8 @@ void installGlobalFunction(
|
||||||
const char* name,
|
const char* name,
|
||||||
JSObjectCallAsFunctionCallback callback);
|
JSObjectCallAsFunctionCallback callback);
|
||||||
|
|
||||||
|
JSValueRef makeJSCException(
|
||||||
|
JSContextRef ctx,
|
||||||
|
const char* exception_text);
|
||||||
|
|
||||||
} }
|
} }
|
||||||
|
|
|
@ -17,7 +17,11 @@ static JSValueRef nativeProfilerStart(
|
||||||
const JSValueRef arguments[],
|
const JSValueRef arguments[],
|
||||||
JSValueRef* exception) {
|
JSValueRef* exception) {
|
||||||
if (argumentCount < 1) {
|
if (argumentCount < 1) {
|
||||||
// Could raise an exception here.
|
if (exception) {
|
||||||
|
*exception = facebook::react::makeJSCException(
|
||||||
|
ctx,
|
||||||
|
"nativeProfilerStart: requires at least 1 argument");
|
||||||
|
}
|
||||||
return JSValueMakeUndefined(ctx);
|
return JSValueMakeUndefined(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +39,11 @@ static JSValueRef nativeProfilerEnd(
|
||||||
const JSValueRef arguments[],
|
const JSValueRef arguments[],
|
||||||
JSValueRef* exception) {
|
JSValueRef* exception) {
|
||||||
if (argumentCount < 1) {
|
if (argumentCount < 1) {
|
||||||
// Could raise an exception here.
|
if (exception) {
|
||||||
|
*exception = facebook::react::makeJSCException(
|
||||||
|
ctx,
|
||||||
|
"nativeProfilerEnd: requires at least 1 argument");
|
||||||
|
}
|
||||||
return JSValueMakeUndefined(ctx);
|
return JSValueMakeUndefined(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,8 +92,11 @@ static JSValueRef nativeTraceBeginSection(
|
||||||
const JSValueRef arguments[],
|
const JSValueRef arguments[],
|
||||||
JSValueRef* exception) {
|
JSValueRef* exception) {
|
||||||
if (FBSYSTRACE_UNLIKELY(argumentCount < 2)) {
|
if (FBSYSTRACE_UNLIKELY(argumentCount < 2)) {
|
||||||
// Could raise an exception here.
|
if (exception) {
|
||||||
// TODO T9329825
|
*exception = facebook::react::makeJSCException(
|
||||||
|
ctx,
|
||||||
|
"nativeTraceBeginSection: requires at least 2 arguments");
|
||||||
|
}
|
||||||
return JSValueMakeUndefined(ctx);
|
return JSValueMakeUndefined(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,8 +132,11 @@ static JSValueRef nativeTraceEndSection(
|
||||||
const JSValueRef arguments[],
|
const JSValueRef arguments[],
|
||||||
JSValueRef* exception) {
|
JSValueRef* exception) {
|
||||||
if (FBSYSTRACE_UNLIKELY(argumentCount < 1)) {
|
if (FBSYSTRACE_UNLIKELY(argumentCount < 1)) {
|
||||||
// Could raise an exception here.
|
if (exception) {
|
||||||
// TODO T9329825
|
*exception = facebook::react::makeJSCException(
|
||||||
|
ctx,
|
||||||
|
"nativeTraceEndSection: requires at least 1 argument");
|
||||||
|
}
|
||||||
return JSValueMakeUndefined(ctx);
|
return JSValueMakeUndefined(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,8 +176,11 @@ static JSValueRef beginOrEndAsync(
|
||||||
const JSValueRef arguments[],
|
const JSValueRef arguments[],
|
||||||
JSValueRef* exception) {
|
JSValueRef* exception) {
|
||||||
if (FBSYSTRACE_UNLIKELY(argumentCount < 3)) {
|
if (FBSYSTRACE_UNLIKELY(argumentCount < 3)) {
|
||||||
// Could raise an exception here.
|
if (exception) {
|
||||||
// TODO T9329825
|
*exception = facebook::react::makeJSCException(
|
||||||
|
ctx,
|
||||||
|
"beginOrEndAsync: requires at least 3 arguments");
|
||||||
|
}
|
||||||
return JSValueMakeUndefined(ctx);
|
return JSValueMakeUndefined(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,8 +239,11 @@ static JSValueRef stageAsync(
|
||||||
const JSValueRef arguments[],
|
const JSValueRef arguments[],
|
||||||
JSValueRef* exception) {
|
JSValueRef* exception) {
|
||||||
if (FBSYSTRACE_UNLIKELY(argumentCount < 4)) {
|
if (FBSYSTRACE_UNLIKELY(argumentCount < 4)) {
|
||||||
// Could raise an exception here.
|
if (exception) {
|
||||||
// TODO T9329825
|
*exception = facebook::react::makeJSCException(
|
||||||
|
ctx,
|
||||||
|
"stageAsync: requires at least 4 arguments");
|
||||||
|
}
|
||||||
return JSValueMakeUndefined(ctx);
|
return JSValueMakeUndefined(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,8 +385,11 @@ static JSValueRef nativeTraceCounter(
|
||||||
const JSValueRef arguments[],
|
const JSValueRef arguments[],
|
||||||
JSValueRef* exception) {
|
JSValueRef* exception) {
|
||||||
if (FBSYSTRACE_UNLIKELY(argumentCount < 3)) {
|
if (FBSYSTRACE_UNLIKELY(argumentCount < 3)) {
|
||||||
// Could raise an exception here.
|
if (exception) {
|
||||||
// TODO T9329825
|
*exception = facebook::react::makeJSCException(
|
||||||
|
ctx,
|
||||||
|
"nativeTraceCounter: requires at least 3 arguments");
|
||||||
|
}
|
||||||
return JSValueMakeUndefined(ctx);
|
return JSValueMakeUndefined(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue