]> git.saurik.com Git - cycript.git/blobdiff - sig/copy.cpp
Don't stack overflow on struct pointers in cycles.
[cycript.git] / sig / copy.cpp
index 3338cd67a824bb28ce9a09df5d930eadbc80a740..63b72fe25ed4e7dfd8bb2d60be881906e73cd7d1 100644 (file)
@@ -57,6 +57,7 @@ String *String::Copy(CYPool &pool, const char *rename) const {
     return new(pool) String();
 }
 
+#ifdef CY_OBJECTIVEC
 Meta *Meta::Copy(CYPool &pool, const char *rename) const {
     return new(pool) Meta();
 }
@@ -64,6 +65,7 @@ Meta *Meta::Copy(CYPool &pool, const char *rename) const {
 Selector *Selector::Copy(CYPool &pool, const char *rename) const {
     return new(pool) Selector();
 }
+#endif
 
 Bits *Bits::Copy(CYPool &pool, const char *rename) const {
     return new(pool) Bits(size);
@@ -77,12 +79,18 @@ Array *Array::Copy(CYPool &pool, const char *rename) const {
     return new(pool) Array(*type.Copy(pool), size);
 }
 
+#ifdef CY_OBJECTIVEC
 Object *Object::Copy(CYPool &pool, const char *rename) const {
     return new(pool) Object(pool.strdup(name));
 }
+#endif
 
 Aggregate *Aggregate::Copy(CYPool &pool, const char *rename) const {
-    Aggregate *copy(new(pool) Aggregate(overlap, rename ?: pool.strdup(name)));
+    if (rename == NULL)
+        rename = pool.strdup(name);
+    else if (rename[0] == '\0')
+        rename = NULL;
+    Aggregate *copy(new(pool) Aggregate(overlap, rename));
     sig::Copy(pool, copy->signature, signature);
     return copy;
 }
@@ -93,11 +101,13 @@ Function *Function::Copy(CYPool &pool, const char *rename) const {
     return copy;
 }
 
+#ifdef CY_OBJECTIVEC
 Block *Block::Copy(CYPool &pool, const char *rename) const {
     Block *copy(new(pool) Block());
     sig::Copy(pool, copy->signature, signature);
     return copy;
 }
+#endif
 
 void Copy(CYPool &pool, ffi_type &lhs, ffi_type &rhs) {
     lhs.size = rhs.size;