Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Main
Synchronet
Commits
14e2ee20
Commit
14e2ee20
authored
Feb 26, 2022
by
Rob Swindell
💬
Browse files
Better error handling in Archive.read()
Inspired by jsdoor's equivalent change.
parent
7448a68a
Pipeline
#2796
passed with stage
in 9 minutes and 38 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
4 deletions
+15
-4
src/sbbs3/js_archive.c
src/sbbs3/js_archive.c
+15
-4
No files found.
src/sbbs3/js_archive.c
View file @
14e2ee20
...
...
@@ -522,17 +522,28 @@ js_read(JSContext *cx, uintN argc, jsval *arglist)
for
(;;)
{
result
=
archive_read_data_block
(
ar
,
&
buff
,
&
size
,
&
offset
);
if
(
result
!
=
ARCHIVE_
OK
)
if
(
result
=
=
ARCHIVE_
EOF
)
break
;
else
if
(
result
!=
ARCHIVE_OK
)
{
JS_ReportError
(
cx
,
"archive_read_next_header() returned %d: %s"
,
result
,
archive_error_string
(
ar
));
retval
=
JS_FALSE
;
break
;
}
char
*
np
=
realloc
(
p
,
total
+
size
);
if
(
np
==
NULL
)
if
(
np
==
NULL
)
{
JS_ReportError
(
cx
,
"realloc failure of %"
PRIi64
" bytes"
,
total
+
size
);
retval
=
JS_FALSE
;
break
;
}
p
=
np
;
memcpy
(
p
+
total
,
buff
,
size
);
total
+=
size
;
}
JSString
*
js_str
=
JS_NewStringCopyN
(
cx
,
p
,
total
);
JS_SET_RVAL
(
cx
,
arglist
,
STRING_TO_JSVAL
(
js_str
));
if
(
retval
==
JS_TRUE
)
{
JSString
*
js_str
=
JS_NewStringCopyN
(
cx
,
p
,
total
);
JS_SET_RVAL
(
cx
,
arglist
,
STRING_TO_JSVAL
(
js_str
));
}
free
(
p
);
break
;
}
...
...
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