From 0ced2e47fe333ec4a4b1222fa298561c5479696c Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Tue, 27 Apr 2010 01:11:12 +0000 Subject: [PATCH] Make CYExecute take a CYUTF8String and fix the size shell game in Console's Run. --- Console.cpp | 5 +++-- Execute.cpp | 2 +- Handler.mm | 2 +- JavaScript.hpp | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Console.cpp b/Console.cpp index 7f4f454..ae5802c 100644 --- a/Console.cpp +++ b/Console.cpp @@ -136,7 +136,7 @@ static CYUTF8String Run(CYPool &pool, int client, CYUTF8String code) { if (client == -1) { mode_ = Running; #ifdef CY_EXECUTE - json = CYExecute(pool, code.data); + json = CYExecute(pool, code); #else json = NULL; #endif @@ -145,8 +145,9 @@ static CYUTF8String Run(CYPool &pool, int client, CYUTF8String code) { size = strlen(json); } else { mode_ = Sending; + size = code.size; CYSendAll(client, &size, sizeof(size)); - CYSendAll(client, code.data, size); + CYSendAll(client, code.data, code.size); mode_ = Waiting; CYRecvAll(client, &size, sizeof(size)); if (size == _not(size_t)) diff --git a/Execute.cpp b/Execute.cpp index 6197bc9..e8ea4ae 100644 --- a/Execute.cpp +++ b/Execute.cpp @@ -1199,7 +1199,7 @@ JSObjectRef CYGetGlobalObject(JSContextRef context) { return JSContextGetGlobalObject(context); } -const char *CYExecute(apr_pool_t *pool, const char *code) { +const char *CYExecute(apr_pool_t *pool, CYUTF8String code) { JSContextRef context(CYGetJSContext()); JSValueRef exception(NULL), result; diff --git a/Handler.mm b/Handler.mm index 833ebf3..01c3cbc 100644 --- a/Handler.mm +++ b/Handler.mm @@ -74,7 +74,7 @@ struct CYExecute_ { CYExecute_ *execute(reinterpret_cast([value pointerValue])); const char *data(execute->data_); execute->data_ = NULL; - execute->data_ = CYExecute(execute->pool_, data); + execute->data_ = CYExecute(execute->pool_, CYUTF8String(data)); } @end diff --git a/JavaScript.hpp b/JavaScript.hpp index f5c487d..4dba607 100644 --- a/JavaScript.hpp +++ b/JavaScript.hpp @@ -69,7 +69,7 @@ JSGlobalContextRef CYGetJSContext(); JSObjectRef CYGetGlobalObject(JSContextRef context); extern "C" void CYSetupContext(JSGlobalContextRef context); -const char *CYExecute(apr_pool_t *pool, const char *code); +const char *CYExecute(apr_pool_t *pool, CYUTF8String code); void CYSetArgs(int argc, const char *argv[]); -- 2.45.2