Skip to content

Commit

Permalink
try fix synctex crash
Browse files Browse the repository at this point in the history
  • Loading branch information
sunderme committed May 24, 2024
1 parent 4773bf8 commit 5bb323c
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/pdfviewer/synctex/synctex_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,7 @@ SYNCTEX_INLINE static void _synctex_will_free(synctex_node_p node) {
* It is not owned by its parent, unless it is its first child.
* This destructor is for all nodes with children.
*/
/*
static void _synctex_free_node(synctex_node_p node) {
if (node) {
SYNCTEX_SCANNER_REMOVE_HANDLE_TO(node);
Expand All @@ -910,10 +911,49 @@ static void _synctex_free_node(synctex_node_p node) {
nextNode=__synctex_tree_sibling(n);
synctex_node_free(_synctex_tree_child(n));
_synctex_free(n);
++i;
} while(n=nextNode);
}
return;
}*/

static void _synctex_free_node(synctex_node_p node) {
if (node) {
SYNCTEX_SCANNER_REMOVE_HANDLE_TO(node);
SYNCTEX_WILL_FREE(node);

do {
synctex_node_p nextSibling=__synctex_tree_sibling(node);
synctex_node_p n=node;
synctex_node_p nextNode=NULL;
do {
while((nextNode=_synctex_tree_child(n))) {
__synctex_tree_set_child(n, NULL);
n=nextNode;
}
if(n){
nextNode=__synctex_tree_sibling(n);
if(!nextNode) {
if(n==node){
_synctex_free(n);
break;
}
nextNode=__synctex_tree_parent(n);
}
_synctex_free(n);
n=nextNode;
}
if(n==node){
_synctex_free(n);
break;
}
} while(n);
node=nextSibling;
}while(node);
}
return;
}

/**
* Free the given handle.
* - parameter node: of type synctex_node_p
Expand Down Expand Up @@ -6072,6 +6112,7 @@ synctex_scanner_p synctex_scanner_new_with_output_file(const char * output, cons

/* The scanner destructor
*/

int synctex_scanner_free(synctex_scanner_p scanner) {
int node_count = 0;
if (scanner) {
Expand Down

0 comments on commit 5bb323c

Please sign in to comment.