cs_disasm: remove code redundancy

(1) added free_array to free the result and avoid possible crash by calling free(insn->detail) when insn->detail is null.

(2) factorized the code to grow the array of instructions and the fetching of the next instruction to disassemble.