Fix potential memory leak in SUUIDModelHash #21

Merged
merged 1 commit into from Sep 26, 2012

Conversation

Projects
None yet
2 participants
Contributor

appden commented Aug 28, 2012

This leak (caught by the static analyzer) would occur if the do-while loop hit a break before free() was called. Instead of allocating memory on the heap, it is now being dynamically allocated on the stack.

Additionally, there was a (very) small chance that the 'result' string would be nil if for some crazy reason the returned value for 'hw.machine' was not a proper UTF-8 encoded string. However unlikely for that to occur, the code was changed for correctness.

@appden appden Fix potential memory leak in SUUIDModelHash
This leak (caught by the static analyzer) would occur if the do-while loop hit a break before free() was called. Instead of allocating memory on the heap, it is now being dynamically allocated on the stack.

Additionally, there was a (very) small chance that the 'result' string would be nil if for some crazy reason the returned value for 'hw.machine' was not a proper UTF-8 encoded string. However unlikely for that to occur, the code was changed for correctness.
d0a268a
Contributor

mattmassicotte commented Sep 26, 2012

Thanks for submitting this - good fix, way simpler.

mattmassicotte merged commit 2ab3f29 into crashlytics:master Sep 26, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment