diff options
author | allen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2000-10-05 13:10:25 +0000 |
---|---|---|
committer | allen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2000-10-05 13:10:25 +0000 |
commit | 277cfb798a609bdc5b7d7ae3f0b155b2aed94ca5 (patch) | |
tree | d2166f8298189f702af08e686031efeb6bc153f1 /src/util/String.c | |
parent | cc27bd7f25823d177d72a1e0591e44a0b285b0cd (diff) |
Fixed bug in Util_SplitFilename.
git-svn-id: http://svn.cactuscode.org/flesh/trunk@1857 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/util/String.c')
-rw-r--r-- | src/util/String.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/util/String.c b/src/util/String.c index da5c1e55..e8a094e7 100644 --- a/src/util/String.c +++ b/src/util/String.c @@ -257,12 +257,14 @@ int Util_SplitString(char **before, char **after, const char *string, const char @@*/ char *Util_Strdup(const char *s) { - char *retstr; + char *retstr=NULL; retstr = (char*) malloc((strlen(s)+1)*sizeof(char)); - - strcpy(retstr,s); - + if(retstr) + { + strcpy(retstr,s); + } + return retstr; } @@ -375,16 +377,13 @@ int Util_StrCmpi(const char *string1, const char *string2) int Util_SplitFilename(char **dir, char **file, const char *string) { int retval=-1; - char *position; + char *position=NULL; char *copy; - copy = (char *)malloc(strlen(string)*sizeof(char)); - - strcpy(copy,string); + copy = Util_Strdup(string); /* Find location of the seperator */ position = strrchr(copy, '/'); - if(position) { retval = 0; |