fresco icon indicating copy to clipboard operation
fresco copied to clipboard

Improve bytearray handling

Open MarcSchoenefeld opened this issue 6 years ago • 6 comments

NewByteArray can fail and return null, consider checking before using the returned value as array https://github.com/facebook/fresco/blob/2ae15501ad3fc132528f100990b9c06de4846e3a/imagepipeline/src/main/jni/imagepipeline/jpeg/jpeg_stream_wrappers.cpp#L135

MarcSchoenefeld avatar Oct 09 '18 21:10 MarcSchoenefeld

Thanks for the suggestions! Feel free to submit a pull request!

oprisnik avatar Oct 10 '18 09:10 oprisnik

Hi @oprisnik I'm trying to work on this issue, may I know what behaviour that we expect when NewByteArray return null? Is run safeThrow enough?

azisuazusa avatar Nov 14 '18 06:11 azisuazusa

Hey! Sorry for the delayed response. I guess throwing should be fine yes. We already throw a couple lines below when the other buffer is null:

if (dest->buffer == NULL) {
    jpegSafeThrow(
        (j_common_ptr) cinfo,
        "Failed to allcoate memory for byte buffer.");
  }

oprisnik avatar Dec 04 '18 15:12 oprisnik

@oprisnik I cannot find this path fresco/imagepipeline/src/main/jni/imagepipeline/jpeg/jpeg_stream_wrappers.cpp

Is this issue still valid? If yes, then where is jpeg_stream_wrappers.cpp moved?

iadeelzafar avatar Nov 10 '19 20:11 iadeelzafar

Hey! Native code was moved to https://github.com/facebook/fresco/blob/a6b47b94b229ea8549ea4bc70bd22970e97ba465/native-imagetranscoder/src/main/jni/native-imagetranscoder/jpeg/jpeg_stream_wrappers.cpp

oprisnik avatar Nov 11 '19 12:11 oprisnik

should this issue still be open?

tsukipedia avatar Jul 12 '23 17:07 tsukipedia