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
Compare Revisions
7448a68a421ac2ebcee4f9b31a8f635c318a522c...14e2ee206051e63e1e7a085bea1f87674355bf23
Commits (1)
Better error handling in Archive.read()
· 14e2ee20
Rob Swindell
authored
Feb 26, 2022
Inspired by jsdoor's equivalent change.
14e2ee20
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
;
}
...
...