Commit d4b10a2041c0b148d2f29f88c28fd82ef6277c7d
1 parent
631c5345
Minor code tweaks: Replace `throw std::runtime_error` with `util::no_ci_rt_error…
…_if` for improved error handling in `QPDFWriter::writeLinearized` and adjust argv parsing in `objects.cc`tests.
Showing
2 changed files
with
8 additions
and
7 deletions
libqpdf/QPDFWriter.cc
| @@ -2859,16 +2859,17 @@ impl::Writer::writeLinearized() | @@ -2859,16 +2859,17 @@ impl::Writer::writeLinearized() | ||
| 2859 | } | 2859 | } |
| 2860 | next_objid = part6_first_obj; | 2860 | next_objid = part6_first_obj; |
| 2861 | enqueuePart(part6); | 2861 | enqueuePart(part6); |
| 2862 | - if (next_objid != after_part6) { | ||
| 2863 | - throw std::runtime_error("error encountered after writing part 6 of linearized data"); | ||
| 2864 | - } | 2862 | + util::no_ci_rt_error_if( |
| 2863 | + next_objid != after_part6, "error encountered after writing part 6 of linearized data" // | ||
| 2864 | + ); | ||
| 2865 | next_objid = second_half_first_obj; | 2865 | next_objid = second_half_first_obj; |
| 2866 | enqueuePart(part7); | 2866 | enqueuePart(part7); |
| 2867 | enqueuePart(part8); | 2867 | enqueuePart(part8); |
| 2868 | enqueuePart(part9); | 2868 | enqueuePart(part9); |
| 2869 | - if (next_objid != after_second_half) { | ||
| 2870 | - throw std::runtime_error("error encountered after writing part 9 of cfg.linearized_ data"); | ||
| 2871 | - } | 2869 | + util::no_ci_rt_error_if( |
| 2870 | + next_objid != after_second_half, | ||
| 2871 | + "error encountered after writing part 9 of linearized data" // | ||
| 2872 | + ); | ||
| 2872 | 2873 | ||
| 2873 | qpdf_offset_t hint_length = 0; | 2874 | qpdf_offset_t hint_length = 0; |
| 2874 | std::string hint_buffer; | 2875 | std::string hint_buffer; |
libtests/objects.cc
| @@ -356,7 +356,7 @@ main(int argc, char* argv[]) | @@ -356,7 +356,7 @@ main(int argc, char* argv[]) | ||
| 356 | try { | 356 | try { |
| 357 | int n = QUtil::string_to_int(argv[1]); | 357 | int n = QUtil::string_to_int(argv[1]); |
| 358 | char const* filename1 = argv[2]; | 358 | char const* filename1 = argv[2]; |
| 359 | - char const* arg2 = argv[3]; | 359 | + char const* arg2 = (argc >= 4) ? argv[3] : ""; |
| 360 | runtest(n, filename1, arg2); | 360 | runtest(n, filename1, arg2); |
| 361 | } catch (std::exception& e) { | 361 | } catch (std::exception& e) { |
| 362 | std::cerr << e.what() << '\n'; | 362 | std::cerr << e.what() << '\n'; |