Skip to content

Commit 5f20a95

Browse files
committed
add fallback catch to avoid exceptions from crossing C boundary
Signed-off-by: Kimball Thurston <kdt3rd@gmail.com>
1 parent e8e0b99 commit 5f20a95

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

src/lib/OpenEXRCore/internal_ht.cpp

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class staticmem_outfile : public ojph::outfile_base
6363
* @param ptr is a pointer to new data.
6464
* @param size the number of bytes in the new data.
6565
*/
66-
size_t write (const void* ptr, size_t sz)
66+
size_t write (const void* ptr, size_t sz) override
6767
{
6868
assert (this->is_open);
6969
assert (this->buf);
@@ -157,8 +157,8 @@ class staticmem_outfile : public ojph::outfile_base
157157
ojph::ui8 *cur_ptr;
158158
};
159159

160-
extern "C" exr_result_t
161-
internal_exr_undo_ht (
160+
static exr_result_t
161+
ht_undo_impl (
162162
exr_decode_pipeline_t* decode,
163163
const void* compressed_data,
164164
uint64_t comp_buf_size,
@@ -329,7 +329,31 @@ internal_exr_undo_ht (
329329
}
330330

331331
extern "C" exr_result_t
332-
internal_exr_apply_ht (exr_encode_pipeline_t* encode)
332+
internal_exr_undo_ht (
333+
exr_decode_pipeline_t* decode,
334+
const void* compressed_data,
335+
uint64_t comp_buf_size,
336+
void* uncompressed_data,
337+
uint64_t uncompressed_size)
338+
{
339+
try
340+
{
341+
return ht_undo_impl (decode, compressed_data, comp_buf_size,
342+
uncompressed_data, uncompressed_size);
343+
}
344+
catch ( ... )
345+
{
346+
}
347+
348+
return EXR_ERR_CORRUPT_CHUNK;
349+
}
350+
351+
352+
////////////////////////////////////////
353+
354+
355+
static exr_result_t
356+
ht_apply_impl (exr_encode_pipeline_t* encode)
333357
{
334358
exr_result_t rv = EXR_ERR_SUCCESS;
335359

@@ -504,3 +528,17 @@ internal_exr_apply_ht (exr_encode_pipeline_t* encode)
504528

505529
return rv;
506530
}
531+
532+
extern "C" exr_result_t
533+
internal_exr_apply_ht (exr_encode_pipeline_t* encode)
534+
{
535+
try
536+
{
537+
return ht_apply_impl (encode);
538+
}
539+
catch ( ... )
540+
{
541+
}
542+
543+
return EXR_ERR_INCORRECT_CHUNK;
544+
}

0 commit comments

Comments
 (0)