diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2023-09-06 16:04:20 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2023-09-10 22:55:42 +0200 |
commit | e8704a8f60041abb84585efaf3223abf0b6dcb90 (patch) | |
tree | 0ad68e72ce1fa010053cb61598c258f2e6a2415b /libavformat/avio.c | |
parent | e26506cb3b2a8c1ee28c13c328e4dcb037555f9e (diff) | |
download | ffmpeg-e8704a8f60041abb84585efaf3223abf0b6dcb90.tar.gz |
avformat/aviobuf: Don't use incompatible function pointer type for call
It is undefined behaviour even in cases where it works
(it works because both are pointers). Instead change
the functions involved to use the type expected by the AVIO-API
and add inline wrappers for our internal callers.
Reviewed-by: Tomas Härdin <git@haerdin.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat/avio.c')
-rw-r--r-- | libavformat/avio.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libavformat/avio.c b/libavformat/avio.c index 74a5936f55..36bee0fa55 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -392,8 +392,10 @@ static inline int retry_transfer_wrapper(URLContext *h, uint8_t *buf, return len; } -int ffurl_read(URLContext *h, unsigned char *buf, int size) +int ffurl_read2(void *urlcontext, uint8_t *buf, int size) { + URLContext *h = urlcontext; + if (!(h->flags & AVIO_FLAG_READ)) return AVERROR(EIO); return retry_transfer_wrapper(h, buf, size, 1, h->prot->url_read); @@ -406,8 +408,10 @@ int ffurl_read_complete(URLContext *h, unsigned char *buf, int size) return retry_transfer_wrapper(h, buf, size, size, h->prot->url_read); } -int ffurl_write(URLContext *h, const unsigned char *buf, int size) +int ffurl_write2(void *urlcontext, uint8_t *buf, int size) { + URLContext *h = urlcontext; + if (!(h->flags & AVIO_FLAG_WRITE)) return AVERROR(EIO); /* avoid sending too big packets */ @@ -419,8 +423,9 @@ int ffurl_write(URLContext *h, const unsigned char *buf, int size) h->prot->url_write); } -int64_t ffurl_seek(URLContext *h, int64_t pos, int whence) +int64_t ffurl_seek2(void *urlcontext, int64_t pos, int whence) { + URLContext *h = urlcontext; int64_t ret; if (!h->prot->url_seek) @@ -641,8 +646,10 @@ int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles) return h->prot->url_get_multi_file_handle(h, handles, numhandles); } -int ffurl_get_short_seek(URLContext *h) +int ffurl_get_short_seek(void *urlcontext) { + URLContext *h = urlcontext; + if (!h || !h->prot || !h->prot->url_get_short_seek) return AVERROR(ENOSYS); return h->prot->url_get_short_seek(h); |