Add a helper for getting array length: tf_util_get_length.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3925 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -488,14 +488,10 @@ static JSValue _tf_ssb_add_rpc(JSContext* context, JSValueConst this_val, int ar
|
||||
return JS_ThrowTypeError(context, "Expected argument 2 to be a function.");
|
||||
}
|
||||
|
||||
JSValue length_val = JS_GetPropertyStr(context, argv[0], "length");
|
||||
int length = 0;
|
||||
JS_ToInt32(context, &length, length_val);
|
||||
JS_FreeValue(context, length_val);
|
||||
|
||||
enum { k_max_name_parts = 16 };
|
||||
const char* name[k_max_name_parts + 1] = { 0 };
|
||||
|
||||
int length = tf_util_get_length(context, argv[0]);
|
||||
if (length >= k_max_name_parts)
|
||||
{
|
||||
return JS_ThrowInternalError(context, "Too many parts to RPC name.");
|
||||
|
Reference in New Issue
Block a user