Index: third_party/brotli/tools/bro.cc |
diff --git a/third_party/brotli/tools/bro.cc b/third_party/brotli/tools/bro.cc |
index 0c2ec76b01b56cfd5dfcf472269c7b35108f8ea0..b254f0ffdb0857e2fd281faca3fe1253c64c9662 100644 |
--- a/third_party/brotli/tools/bro.cc |
+++ b/third_party/brotli/tools/bro.cc |
@@ -287,10 +287,16 @@ |
brotli::BrotliParams params; |
params.lgwin = lgwin; |
params.quality = quality; |
- brotli::BrotliFileIn in(fin, 1 << 16); |
- brotli::BrotliFileOut out(fout); |
- if (!BrotliCompress(params, &in, &out)) { |
- fprintf(stderr, "compression failed\n"); |
+ try { |
+ brotli::BrotliFileIn in(fin, 1 << 16); |
+ brotli::BrotliFileOut out(fout); |
+ if (!BrotliCompress(params, &in, &out)) { |
+ fprintf(stderr, "compression failed\n"); |
+ unlink(output_path); |
+ exit(1); |
+ } |
+ } catch (std::bad_alloc&) { |
+ fprintf(stderr, "not enough memory\n"); |
unlink(output_path); |
exit(1); |
} |