regex: use regexec_buf()
[gitweb.git] / builtin / apply.c
index dbdfa9b646f5891628e15278bf559a2397769754..ce3b77853c7a409b40d14400172327978266f9ca 100644 (file)
@@ -4371,8 +4371,10 @@ static int apply_patch(int fd, const char *filename, int options)
                patch->inaccurate_eof = !!(options & INACCURATE_EOF);
                patch->recount =  !!(options & RECOUNT);
                nr = parse_chunk(buf.buf + offset, buf.len - offset, patch);
-               if (nr < 0)
+               if (nr < 0) {
+                       free_patch(patch);
                        break;
+               }
                if (apply_in_reverse)
                        reverse_patches(patch);
                if (use_patch(patch)) {