[FFmpeg-cvslog] avutil/opt: Document actual behaviour of av_opt_copy a bit more
Andreas Rheinhardt
git at videolan.org
Tue Aug 17 20:50:03 EEST 2021
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Fri Aug 13 08:48:42 2021 +0200| [8c53b14599330f08859082c868d7df559e9385e5] | committer: Andreas Rheinhardt
avutil/opt: Document actual behaviour of av_opt_copy a bit more
In particular, document that av_opt_copy() always disentangles
allocated options even on error; this guarantee is needed to e.g.
properly free duplicated thread contexts in libavcodec on error.
Reviewed-by: Michael Niedermayer <michael at niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8c53b14599330f08859082c868d7df559e9385e5
---
doc/APIchanges | 4 ++++
libavutil/opt.h | 7 +++++++
libavutil/version.h | 2 +-
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 28cc0344ad..393ae68fa7 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,10 @@ libavutil: 2021-04-27
API changes, most recent first:
+2021-08-17 - xxxxxxxxxx - lavu 57.4.101 - opt.h
+ av_opt_copy() now guarantees that allocated src and dst options
+ don't alias each other even on error.
+
2021-08-14 - xxxxxxxxxx - lavu 57.4.100 - imgutils.h
Add av_image_copy_plane_uc_from()
diff --git a/libavutil/opt.h b/libavutil/opt.h
index 9e1e8ede06..2820435eec 100644
--- a/libavutil/opt.h
+++ b/libavutil/opt.h
@@ -790,9 +790,16 @@ int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags
/**
* Copy options from src object into dest object.
*
+ * The underlying AVClass of both src and dest must coincide. The guarantee
+ * below does not apply if this is not fulfilled.
+ *
* Options that require memory allocation (e.g. string or binary) are malloc'ed in dest object.
* Original memory allocated for such options is freed unless both src and dest options points to the same memory.
*
+ * Even on error it is guaranteed that allocated options from src and dest
+ * no longer alias each other afterwards; in particular calling av_opt_free()
+ * on both src and dest is safe afterwards if dest has been memdup'ed from src.
+ *
* @param dest Object to copy from
* @param src Object to copy into
* @return 0 on success, negative on error
diff --git a/libavutil/version.h b/libavutil/version.h
index 201b012596..4b77387b08 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -80,7 +80,7 @@
#define LIBAVUTIL_VERSION_MAJOR 57
#define LIBAVUTIL_VERSION_MINOR 4
-#define LIBAVUTIL_VERSION_MICRO 100
+#define LIBAVUTIL_VERSION_MICRO 101
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
More information about the ffmpeg-cvslog
mailing list