Soft Works: > > >> -----Original Message----- >> From: ffmpeg-devel <ffmpeg-devel-boun...@ffmpeg.org> On Behalf Of Andreas >> Rheinhardt >> Sent: Wednesday, 22 September 2021 04:05 >> To: ffmpeg-devel@ffmpeg.org >> Subject: Re: [FFmpeg-devel] [PATCH v8 13/13] avfilter/graphicsub2text: Add >> new graphicsub2text filter (OCR) >> >>> + >>> +static void uninit(AVFilterContext *ctx) >>> +{ >>> + SubOcrContext *s = ctx->priv; >>> + >>> + TessBaseAPIEnd(s->tapi); >>> + TessBaseAPIDelete(s->tapi); >> >> Beware: uninit is also called on init failure, so it might be that >> s->tapi is NULL or that TessBaseAPIInit4 did not succeed. > > vf_ocr does it in the same way, so I assumed it to be safe. >
I wish it were that easy. Our own APIs are (usually) safe in the sense that an object that has been memset to zero (as all those contexts are initially) can be passed to the free function even when it has never been initialized. But this is need not be true for external APIs. And unfortunately error paths are often untested. For a bad example, just take a look at vf_libvmaf.c: It's uninit function locks a mutex, regardless of whether said mutex has been initialized at all. That's UB. > Unfortunately there's no proper API documentation for tesseract. > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".