diff options
author | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2006-11-16 18:46:36 +0000 |
---|---|---|
committer | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2006-11-16 18:46:36 +0000 |
commit | b33e5a40c34f9c133ef2722c206d85b34aa9749d (patch) | |
tree | 4110fbd4a1c6ca8b9dca0203de53672df810d4c4 | |
parent | 67ef4bf49c9f9c5728c729a95c58fe63e6d5b328 (diff) |
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
-rw-r--r-- | recordmydesktop/src/init_encoder.c | 15 |
1 files 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; } |