mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-01-03 16:20:17 +01:00
[script] Enable error handling for recursive scanners
It's conceivable that a script could execute another file and so we should only setjmp on the first invocation.
This commit is contained in:
parent
963664727b
commit
f7021d8f3e
2 changed files with 13 additions and 3 deletions
|
|
@ -424,6 +424,7 @@ union _csi_union_object {
|
|||
|
||||
struct _csi_scanner {
|
||||
jmp_buf jmpbuf;
|
||||
int depth;
|
||||
|
||||
enum {
|
||||
NONE,
|
||||
|
|
|
|||
|
|
@ -1101,13 +1101,22 @@ _csi_scan_file (csi_t *ctx, csi_scanner_t *scan, csi_file_t *src)
|
|||
};
|
||||
csi_status_t status;
|
||||
|
||||
if ((status = setjmp (scan->jmpbuf)))
|
||||
return status;
|
||||
/* This function needs to be reentrant to handle recursive scanners.
|
||||
* i.e. one script executes a second.
|
||||
*/
|
||||
|
||||
scan->line_number = 0;
|
||||
if (scan->depth++ == 0) {
|
||||
if ((status = setjmp (scan->jmpbuf))) {
|
||||
scan->depth = 0;
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
scan->line_number = 0; /* XXX broken by recursive scanning */
|
||||
while (func[scan->state] (ctx, scan, src))
|
||||
;
|
||||
|
||||
--scan->depth;
|
||||
return CSI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue