summaryrefslogtreecommitdiff
path: root/libswscale/swscale.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2021-05-19 11:55:22 +0200
committerAnton Khirnov <anton@khirnov.net>2021-07-03 15:31:18 +0200
commit2730639259f5bdf81d4223cd8f4275e2939a1482 (patch)
tree384dcb4387905cf18989847208c0d2630a802078 /libswscale/swscale.c
parentc05cab34a9d53c6b948e3757385b9c2657608603 (diff)
sws: group the parameters validity checks together
Also, fail with an error code rather than 0.
Diffstat (limited to 'libswscale/swscale.c')
-rw-r--r--libswscale/swscale.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 1cf89e4684..37c7cf60dd 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -890,6 +890,15 @@ int attribute_align_arg sws_scale(struct SwsContext *c,
return AVERROR(EINVAL);
}
+ if (!check_image_pointers(srcSlice, c->srcFormat, srcStride)) {
+ av_log(c, AV_LOG_ERROR, "bad src image pointers\n");
+ return AVERROR(EINVAL);
+ }
+ if (!check_image_pointers((const uint8_t* const*)dst, c->dstFormat, dstStride)) {
+ av_log(c, AV_LOG_ERROR, "bad dst image pointers\n");
+ return AVERROR(EINVAL);
+ }
+
if (c->gamma_flag && c->cascaded_context[0])
return scale_gamma(c, srcSlice, srcStride, srcSliceY, srcSliceH, dst, dstStride);
@@ -905,15 +914,6 @@ int attribute_align_arg sws_scale(struct SwsContext *c,
if (srcSliceH == 0)
return 0;
- if (!check_image_pointers(srcSlice, c->srcFormat, srcStride)) {
- av_log(c, AV_LOG_ERROR, "bad src image pointers\n");
- return 0;
- }
- if (!check_image_pointers((const uint8_t* const*)dst, c->dstFormat, dstStride)) {
- av_log(c, AV_LOG_ERROR, "bad dst image pointers\n");
- return 0;
- }
-
if (c->sliceDir == 0 && srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) {
av_log(c, AV_LOG_ERROR, "Slices start in the middle!\n");
return 0;