From: Jay Freeman (saurik) Date: Sun, 16 Sep 2012 03:45:03 +0000 (-0700) Subject: Use CYStringify in Type.toCYON to handle quotations. X-Git-Tag: v0.9.461~1 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/4a8523e5dca7ec6e0ccfb9d85d35cf4cac209f55?ds=sidebyside Use CYStringify in Type.toCYON to handle quotations. --- diff --git a/Execute.cpp b/Execute.cpp index 0afd098..74f29f2 100644 --- a/Execute.cpp +++ b/Execute.cpp @@ -1214,13 +1214,9 @@ static JSValueRef Type_callAsFunction_toCYON(JSContextRef context, JSObjectRef o Type_privateData *internal(reinterpret_cast(JSObjectGetPrivate(_this))); CYPool pool; const char *type(sig::Unparse(pool, internal->type_)); - size_t size(strlen(type)); - char *cyon(new(pool) char[12 + size + 1]); - memcpy(cyon, "new Type(\"", 10); - cyon[12 + size] = '\0'; - cyon[12 + size - 2] = '"'; - cyon[12 + size - 1] = ')'; - memcpy(cyon + 10, type, size); + std::ostringstream str; + CYStringify(str, type, strlen(type)); + char *cyon(apr_pstrcat(pool, "new Type(", str.str().c_str(), ")", NULL)); return CYCastJSValue(context, CYJSString(cyon)); } CYCatch }