set @insn to NULL on error in cs_disasm_ex()
diff --git a/cs.c b/cs.c
index 49e9504..bb44e5b 100644
--- a/cs.c
+++ b/cs.c
@@ -489,6 +489,7 @@
 					}
 
 					cs_mem_free(total);
+					*insn = NULL;
 					handle->errnum = CS_ERR_MEM;
 					return 0;
 				}
@@ -557,6 +558,7 @@
 					}
 
 					cs_mem_free(total);
+					*insn = NULL;
 					handle->errnum = CS_ERR_MEM;
 					return 0;
 				}
@@ -588,6 +590,7 @@
 			}
 
 			cs_mem_free(total);
+			*insn = NULL;
 
 			handle->errnum = CS_ERR_MEM;
 			return 0;