(unnamed)

text/plain

Filename: (unnamed)
Type: text/plain
Part: 0
Message: Re: [BUGS] ECPG memory leak detected
*** ecpglib.c.orig	Tue Dec 14 12:27:47 1999
--- ecpglib.c	Tue Dec 14 12:28:00 1999
***************
*** 528,540 ****
  					{
  						int			slen = strlen((char *) var->value);
  
! 						if (!(newcopy = ecpg_alloc(slen + 1, stmt->lineno)))
  							return false;
  
! 						strncpy(newcopy, (char *) var->value, slen);
! 						newcopy[slen] = '\0';
  
! 						tobeinserted = newcopy;
  					}
  					break;
  				case ECPGt_varchar:
--- 528,540 ----
  					{
  						int			slen = strlen((char *) var->value);
  
! 						if (!(mallocedval = ecpg_alloc(slen + 1, stmt->lineno)))
  							return false;
  
! 						strncpy(mallocedval, (char *) var->value, slen);
! 						mallocedval[slen] = '\0';
  
! 						tobeinserted = mallocedval;
  					}
  					break;
  				case ECPGt_varchar:
***************
*** 1132,1144 ****
  		con->committed = true;
  
  		/* deallocate all prepared statements */
! 		for (this = prep_stmts; this != NULL; this = this->next)
! 		{
! 			bool		b = ECPGdeallocate(lineno, this->name);
  
  			if (!b)
  				return false;
  		}
  	}
  
  	return true;
--- 1132,1144 ----
  		con->committed = true;
  
  		/* deallocate all prepared statements */
! 		while(prep_stmts != NULL) {
! 			bool		b = ECPGdeallocate(lineno, prep_stmts->name);
  
  			if (!b)
  				return false;
  		}
+ 			
  	}
  
  	return true;
***************
*** 1416,1421 ****
--- 1416,1422 ----
  		else
  			prep_stmts = this->next;
  
+ 		free(this);
  		return true;
  	}
  	ECPGlog("deallocate_prepare: invalid statement name %s\n", name);