Summary: Both `stringWithUTF8String` and `stringWithString` implements copy semantics that copies the content of their parameter into a newly allocated buffer. We modeled this as pointer assignment in the past, which means that once we write ``` NSString* foo() { char buf[...]; ... return [NSString stringWithUTF8String:buf]; } ``` We are going to get a spurious stack variable address escape report because local pointer `buf` is assigned to the newly created string and the string gets returned. This diff tries to address the issue by heap-allocating a buffer and `memcpy` the contents in `stringWithUTF8String` and `stringWithString`. But this change will create another problem: the allocated buffer will be reported as leaked by the backend, while in reality those buffers won't actually be leaked as they are allocated in a region that will be periodically autoreleased. To suppress spurious memory leak FPs, I added another attribute `Awont_leak` that will suppress the leakage report on any expressions that get tagged with it. Reviewed By: jeremydubreil Differential Revision: D5403084 fbshipit-source-id: df6de7fmaster
parent
bd90e80859
commit
a8897c2412
Loading…
Reference in new issue