fix #822 & related mess
more up directories if the radare2 directory is rather deep
Fix multuples possible issues

- unchecked malloc return
- possible division by 0
Fix CID 1205216