From b33e5a40c34f9c133ef2722c206d85b34aa9749d Mon Sep 17 00:00:00 2001 From: iovar Date: Thu, 16 Nov 2006 18:46:36 +0000 Subject: added 1 more byte in base_name malloc(terminating zero was missing from length). git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@172 f606c939-3180-4ac9-a4b8-4b8779d57d0a --- recordmydesktop/src/init_encoder.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/recordmydesktop/src/init_encoder.c b/recordmydesktop/src/init_encoder.c index 84d36aa..618c790 100644 --- a/recordmydesktop/src/init_encoder.c +++ b/recordmydesktop/src/init_encoder.c @@ -29,10 +29,10 @@ int IncrementalNaming(char **name){ struct stat buff; - char *base_name; + char *base_name__; int i=0; - base_name=malloc(strlen(*name)); - strcpy(base_name,*name); + base_name__=malloc(strlen(*name)+1); + strcpy(base_name__,*name); //this will go on an endless loop if you have 65536? files with the same name //or it will crash and die.anyone interested in trying ? @@ -41,17 +41,20 @@ int IncrementalNaming(char **name){ char *tname=malloc(strlen(*name)+10); char numbuf[8]; - strcpy(tname,base_name); + strcpy(tname,base_name__); strcat(tname,"."); - I16TOA((++i),numbuf) + i++; + I16TOA((i),numbuf) strcat(tname,numbuf); //save new name + free(*name); *name=malloc(strlen(tname)+1); strcpy(*name,tname); free(tname); } - free(base_name); + + free(base_name__); return 0; } -- cgit v1.2.3