cherry-pick.FILE5_34-15-ge0805be4.fix-leak-on-error-found-by-coverity.patch 692 B

1234567891011121314151617181920
  1. Subject: Fix leak on error, found by coverity
  2. Origin: FILE5_34-15-ge0805be4 <https://github.com/file/file/commit/FILE5_34-15-ge0805be4>
  3. Upstream-Author: Christos Zoulas <christos@zoulas.com>
  4. Date: Wed Aug 1 09:59:45 2018 +0000
  5. --- a/src/compress.c
  6. +++ b/src/compress.c
  7. @@ -247,8 +247,11 @@
  8. * XXX: If file_buffer fails here, we overwrite
  9. * the compressed text. FIXME.
  10. */
  11. - if (file_buffer(ms, -1, NULL, buf, nbytes) == -1)
  12. + if (file_buffer(ms, -1, NULL, buf, nbytes) == -1) {
  13. + if (file_pop_buffer(ms, pb) != NULL)
  14. + abort();
  15. goto error;
  16. + }
  17. if ((rbuf = file_pop_buffer(ms, pb)) != NULL) {
  18. if (file_printf(ms, "%s", rbuf) == -1) {
  19. free(rbuf);