Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
997e2b59
Commit
997e2b59
authored
Jul 26, 2013
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sgidec: return meaningful error codes
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
5efa5103
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
sgidec.c
libavcodec/sgidec.c
+9
-8
No files found.
libavcodec/sgidec.c
View file @
997e2b59
...
...
@@ -41,7 +41,7 @@ typedef struct SgiState {
* @param out_buf Points to one line after the output buffer.
* @param out_end end of line in output buffer
* @param pixelstride pixel stride of input buffer
* @return size of output in bytes,
-1 if buffer overflows
* @return size of output in bytes,
else return error code.
*/
static
int
expand_rle_row
(
SgiState
*
s
,
uint8_t
*
out_buf
,
uint8_t
*
out_end
,
int
pixelstride
)
...
...
@@ -58,7 +58,8 @@ static int expand_rle_row(SgiState *s, uint8_t *out_buf,
}
/* Check for buffer overflow. */
if
(
out_buf
+
pixelstride
*
(
count
-
1
)
>=
out_end
)
return
-
1
;
if
(
out_buf
+
pixelstride
*
(
count
-
1
)
>=
out_end
)
return
AVERROR_INVALIDDATA
;
if
(
pixel
&
0x80
)
{
while
(
count
--
)
{
...
...
@@ -81,7 +82,7 @@ static int expand_rle_row(SgiState *s, uint8_t *out_buf,
* Read a run length encoded SGI image.
* @param out_buf output buffer
* @param s the current image state
* @return 0 if no error, else return error
number
.
* @return 0 if no error, else return error
code
.
*/
static
int
read_rle_sgi
(
uint8_t
*
out_buf
,
SgiState
*
s
)
{
...
...
@@ -115,7 +116,7 @@ static int read_rle_sgi(uint8_t *out_buf, SgiState *s)
* Read an uncompressed SGI image.
* @param out_buf output buffer
* @param s the current image state
* @return 0 if read success,
otherwise return -1
.
* @return 0 if read success,
else return error code
.
*/
static
int
read_uncompressed_sgi
(
unsigned
char
*
out_buf
,
SgiState
*
s
)
{
...
...
@@ -181,13 +182,13 @@ static int decode_frame(AVCodecContext *avctx,
if
(
s
->
bytes_per_channel
!=
1
&&
(
s
->
bytes_per_channel
!=
2
||
rle
))
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"wrong channel number
\n
"
);
return
-
1
;
return
AVERROR_INVALIDDATA
;
}
/* Check for supported image dimensions. */
if
(
dimension
!=
2
&&
dimension
!=
3
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"wrong dimension number
\n
"
);
return
-
1
;
return
AVERROR_INVALIDDATA
;
}
if
(
s
->
depth
==
SGI_GRAYSCALE
)
{
...
...
@@ -198,11 +199,11 @@ static int decode_frame(AVCodecContext *avctx,
avctx
->
pix_fmt
=
s
->
bytes_per_channel
==
2
?
AV_PIX_FMT_RGBA64BE
:
AV_PIX_FMT_RGBA
;
}
else
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"wrong picture format
\n
"
);
return
-
1
;
return
AVERROR_INVALIDDATA
;
}
if
(
av_image_check_size
(
s
->
width
,
s
->
height
,
0
,
avctx
))
return
-
1
;
return
AVERROR_INVALIDDATA
;
avcodec_set_dimensions
(
avctx
,
s
->
width
,
s
->
height
);
if
((
ret
=
ff_get_buffer
(
avctx
,
p
,
0
))
<
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment