[FFmpeg-devel] [PATCH] ffprobe: add compact and compactnk writers

Stefano Sabatini stefasab at gmail.com
Wed Oct 12 15:56:28 CEST 2011


On date Saturday 2011-10-08 15:46:58 +0200, Stefano Sabatini encoded:
> On date Sunday 2011-10-02 12:57:21 +0200, Stefano Sabatini encoded:
[...]
> From c8405eec28c6a5d89874f324e9c6aef83a343907 Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefasab at gmail.com>
> Date: Sun, 2 Oct 2011 11:25:44 +0200
> Subject: [PATCH] ffprobe: add compact writer

Squashed the three patches to one, and changed the escaping algos so
that now they avoid to call printf for each character.

I'm pre-computing the size of the escaped string, reallocating a
global buffer in case it is too short.

I prefer this approach over the ones adopted in json_escape_str() for
avoiding the malloc/free.

Drawbacks: if the string is too big to be contained in SIZE_MAX or if
the buffer can't be reallocated, NULL is returned; also we may keep in
memory a huge buffer in case there is a single huge string.

I add that these problems are more theoretical than practical, but for
the case of crafted files, so I don't want to complicate the code even
more and handle the case of truncated escaped strings.

Now I just need to handle NULL strings returned by the escaping
function (they may crash printf when NULL is not supported, e.g. on
Solaris), I could use av_x_if_null and/or return a special string, e.g.
tag:title=FFPROBE_TOO_BIG_STRING, 
tag:title=FFPROBE_THIS_STRING_COULD_NOT_BE_ESCAPED

and warn.

Opinions?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ffprobe-add-compact-writer.patch
Type: text/x-diff
Size: 10762 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20111012/bfb84cf7/attachment.bin>


More information about the ffmpeg-devel mailing list