Fix shaderc leaks (#1313)

* Fix fcpp memory leaks

* Fix glsl_optimizer leaks
This commit is contained in:
Lectem
2018-01-13 19:08:03 +01:00
committed by Branimir Karadžić
parent 9be9848f9b
commit 7960b42c90
6 changed files with 42 additions and 5 deletions

11
3rdparty/fcpp/cpp1.c vendored
View File

@@ -42,6 +42,7 @@ int fppPreProcess(struct fppTag *tags)
{
size_t i=0;
ReturnCode ret; /* cpp return code */
int retVal; /* fppPreProcess return code */
struct Global *global;
global=(struct Global *)malloc(sizeof(struct Global));
@@ -144,10 +145,16 @@ int fppPreProcess(struct fppTag *tags)
}
fflush(stdout);
// BK - fclose(stdout);
delalldefines(global);
retVal = IO_NORMAL;
if (global->errors > 0 && !global->eflag)
return(IO_ERROR);
return(IO_NORMAL); /* No errors or -E option set */
retVal = IO_ERROR;
free(global->tokenbuf);
free(global->functionname);
free(global->spacebuf);
free(global);
return retVal; /* No errors or -E option set */
}
INLINE FILE_LOCAL

View File

@@ -363,7 +363,7 @@ ReturnCode initdefines(struct Global *global)
return(FPP_OK);
}
void deldefines(struct Global *global)
void delbuiltindefines(struct Global *global)
{
/*
* Delete the built-in #define's.

25
3rdparty/fcpp/cpp6.c vendored
View File

@@ -619,12 +619,35 @@ DEFBUF *defendel(struct Global *global,
}
void delalldefines(struct Global *global)
{
/*
* Delete all the defines in the tables and free memory
*/
DEFBUF *dp;
DEFBUF *prevp;
int i;
for (i = 0; i < SBSIZE; ++i)
{
prevp = global->symtab[i];
while ((dp = prevp) != (DEFBUF *)NULL) {
prevp = dp->link;
free(dp->repl); /* Free the replacement */
free((char *)dp); /* Free the symbol */
}
global->symtab[i] = NULL;
}
}
void outdefines(struct Global *global)
{
DEFBUF *dp;
DEFBUF **syp;
deldefines(global); /* Delete built-in #defines */
delbuiltindefines(global); /* Delete built-in #defines */
for (syp = global->symtab; syp < &global->symtab[SBSIZE]; syp++) {
if ((dp = *syp) != (DEFBUF *) NULL) {
do {

View File

@@ -407,7 +407,8 @@ void dumpadef(char *, register DEFBUF *);
#endif
ReturnCode openfile(struct Global *,char *);
int cget(struct Global *);
void deldefines(struct Global *);
void delbuiltindefines(struct Global *);
void delalldefines(struct Global *);
char *Getmem(struct Global *, int);
ReturnCode openinclude(struct Global *, char *, int);
ReturnCode expstuff(struct Global *, char *, char *);