Revision: 14867
http://sourceforge.net/p/skim-app/code/14867
Author: hofman
Date: 2025-01-15 18:11:17 +0000 (Wed, 15 Jan 2025)
Log Message:
-----------
Fix a memory leak in synctex parser
Modified Paths:
--------------
trunk/vendorsrc/jeromelaurens/synctex-parser/synctex_parser.c
Modified: trunk/vendorsrc/jeromelaurens/synctex-parser/synctex_parser.c
===================================================================
--- trunk/vendorsrc/jeromelaurens/synctex-parser/synctex_parser.c
2025-01-15 17:01:20 UTC (rev 14866)
+++ trunk/vendorsrc/jeromelaurens/synctex-parser/synctex_parser.c
2025-01-15 18:11:17 UTC (rev 14867)
@@ -4361,6 +4361,7 @@
size_t already_len = 0;
_synctex_zs_s zs = {0,0};
char * string = NULL;
+ char * new_string = NULL;
if (NULL == scanner) {
return (_synctex_ss_s){NULL,SYNCTEX_STATUS_BAD_ARGUMENT};
}
@@ -4369,8 +4370,10 @@
more_characters:
zs = _synctex_buffer_get_available_size(scanner,1);
if (zs.status < SYNCTEX_STATUS_EOF) {
+ free(string);
return (_synctex_ss_s){NULL,zs.status};
} else if (0 == zs.size) {
+ free(string);
return (_synctex_ss_s){NULL,SYNCTEX_STATUS_EOF};
}
}
@@ -4387,7 +4390,9 @@
* or *end == '\n' */
len = end - SYNCTEX_CUR;
if (len<UINT_MAX-already_len) {
- if ((string = realloc(string,len+already_len+1)) != NULL) {
+ if ((new_string = realloc(string,len+already_len+1)) != NULL) {
+ string = new_string;
+ new_string = NULL;
if (memcpy(string+already_len,SYNCTEX_CUR,len)) {
already_len += len;
string[already_len]='\0'; /* Terminate the string */
@@ -4412,6 +4417,7 @@
return (_synctex_ss_s){NULL,SYNCTEX_STATUS_ERROR};
}
}
+ free(string);
_synctex_error("could not (re)allocate memory (1).");
return (_synctex_ss_s){NULL,SYNCTEX_STATUS_ERROR};
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit