]> git.saurik.com Git - cycript.git/blobdiff - List.hpp
CYPool::str*dup was leaking memory via global new.
[cycript.git] / List.hpp
index f218f54fe510843406222d156f1380105eb50375..30390eb0786795a40f065eabc2088ac85398d8cf 100644 (file)
--- a/List.hpp
+++ b/List.hpp
@@ -53,14 +53,14 @@ Type_ *&CYSetLast(Type_ *&list) {
 }
 
 template <typename Type_>
-Type_ *CYGetLast(Type_ *list) {
+Type_ *&CYGetLast(Type_ *&list) {
     if (list == NULL)
-        return NULL;
+        return list;
 
-    Type_ *next(list);
-    while (next->next_ != NULL)
-        next = next->next_;
-    return next;
+    Type_ **next(&list);
+    while ((*next)->next_ != NULL)
+        next = &(*next)->next_;
+    return *next;
 }
 
 #define CYForEach(value, list) \