mirror of
https://github.com/rkd77/elinks.git
synced 2025-02-02 15:09:23 -05:00
Debian bug 534835: Don't assert ecmascript_reset_state succeeds
After the recent ecmascript_get_interpreter change, I got an assertion failure in render_document, which calls ecmascript_reset_state and then asserts that it has set vs->ecmascript != NULL. ecmascript_reset_state cannot guarantee that because there might not even be enough free memory for mem_calloc(1, sizeof(struct ecmascript_interpreter). So, replace the assertion in render_document with error handling, and likewise in call_onsubmit_and_submit.
This commit is contained in:
parent
11c0cb859b
commit
e452420d5f
@ -392,17 +392,23 @@ render_document(struct view_state *vs, struct document_view *doc_view,
|
|||||||
&& vs->ecmascript->onload_snippets_cache_id
|
&& vs->ecmascript->onload_snippets_cache_id
|
||||||
&& document->cache_id != vs->ecmascript->onload_snippets_cache_id))
|
&& document->cache_id != vs->ecmascript->onload_snippets_cache_id))
|
||||||
ecmascript_reset_state(vs);
|
ecmascript_reset_state(vs);
|
||||||
assert(vs->ecmascript);
|
/* If ecmascript_reset_state cannot construct a new
|
||||||
vs->ecmascript->onload_snippets_cache_id = document->cache_id;
|
* ECMAScript interpreter, it sets vs->ecmascript =
|
||||||
|
* NULL and vs->ecmascript_fragile = 1. */
|
||||||
|
if (vs->ecmascript) {
|
||||||
|
vs->ecmascript->onload_snippets_cache_id = document->cache_id;
|
||||||
|
|
||||||
/* Passing of the onload_snippets pointers gives *_snippets()
|
/* Passing of the onload_snippets pointers
|
||||||
* some feeling of universality, shall we ever get any other
|
* gives *_snippets() some feeling of
|
||||||
* snippets (?). */
|
* universality, shall we ever get any other
|
||||||
add_snippets(vs->ecmascript,
|
* snippets (?). */
|
||||||
&document->onload_snippets,
|
add_snippets(vs->ecmascript,
|
||||||
&vs->ecmascript->onload_snippets);
|
&document->onload_snippets,
|
||||||
process_snippets(vs->ecmascript, &vs->ecmascript->onload_snippets,
|
&vs->ecmascript->onload_snippets);
|
||||||
&vs->ecmascript->current_onload_snippet);
|
process_snippets(vs->ecmascript,
|
||||||
|
&vs->ecmascript->onload_snippets,
|
||||||
|
&vs->ecmascript->current_onload_snippet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -923,7 +923,15 @@ call_onsubmit_and_submit(struct session *ses, struct document_view *doc_view,
|
|||||||
if (vs->ecmascript_fragile)
|
if (vs->ecmascript_fragile)
|
||||||
ecmascript_reset_state(vs);
|
ecmascript_reset_state(vs);
|
||||||
interpreter = vs->ecmascript;
|
interpreter = vs->ecmascript;
|
||||||
assert(interpreter);
|
/* If there is an onsubmit script and we want
|
||||||
|
* to run it, but the ECMAScript interpreter
|
||||||
|
* cannot be initialized, then don't submit. */
|
||||||
|
if (!interpreter) {
|
||||||
|
done_string(&code);
|
||||||
|
/* See the comment below for the
|
||||||
|
* return value. */
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
add_to_string(&code, fc->form->onsubmit);
|
add_to_string(&code, fc->form->onsubmit);
|
||||||
res = ecmascript_eval_boolback(interpreter, &code);
|
res = ecmascript_eval_boolback(interpreter, &code);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user