facebook / fishhook

A library that enables dynamically rebinding symbols in Mach-O binaries running on iOS.
BSD 3-Clause "New" or "Revised" License
5.17k stars 965 forks source link

we find a memory leak in fishhook function "prepend_rebindings",line 67 #48

Closed rosen0510 closed 6 years ago

rosen0510 commented 6 years ago

new_entry->rebindings = (struct rebinding *) malloc(sizeof(struct rebinding) * nel); This malloc region didn't free in appropriate position

dinhvh commented 6 years ago

In fishhook, entries are not removed. Then, we keep them in memory forever.

rosen0510 commented 6 years ago

The "new_enry->rebindings" can't be accessed in anywhere after that function, why don't you free it ? It's there any special reason ?

dinhvh commented 6 years ago

It can be accessed via new_entry.

rosen0510 commented 6 years ago

But in function "rebind_symbos_image" ,line 190, you freed the "rebinds_head" which is the same as "new_entry".

dinhvh commented 6 years ago

Could you send a pull request to solve it then?

rosen0510 commented 6 years ago

ok

megCanicalKb commented 6 years ago

https://github.com/facebook/fishhook/commit/06cfb582bd9279879894bfd9cc9e562cc6e4b01e