diff options
author | Endi S. Dewata <edewata@redhat.com> | 2010-07-18 17:41:15 -0500 |
---|---|---|
committer | Noriko Hosoi <nhosoi@redhat.com> | 2010-08-20 13:05:27 -0700 |
commit | ec118b1ed616e7405e801179468dc101f0afdf6b (patch) | |
tree | 156ec745fdce1edb5ac239a3d719435ff99941e6 /lib/libsi18n | |
parent | 26ef098df77f66e027719924ac84ebc00bf069aa (diff) | |
download | ds-ec118b1ed616e7405e801179468dc101f0afdf6b.tar.gz ds-ec118b1ed616e7405e801179468dc101f0afdf6b.tar.xz ds-ec118b1ed616e7405e801179468dc101f0afdf6b.zip |
Bug 616500 - fix coverify Defect Type: Resource leaks issues CID 12094 - 12136
https://bugzilla.redhat.com/show_bug.cgi?id=616500
Resolves: bug 616500
Bug description: fix coverify Defect Type: Resource leaks issues CID 12136
description: Fixed resource leaks in XP_MakeStringProperties().
Diffstat (limited to 'lib/libsi18n')
-rw-r--r-- | lib/libsi18n/makstrdb.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/libsi18n/makstrdb.c b/lib/libsi18n/makstrdb.c index c96c4d54..2ced26e9 100644 --- a/lib/libsi18n/makstrdb.c +++ b/lib/libsi18n/makstrdb.c @@ -160,13 +160,21 @@ XP_MakeStringProperties(void) int j; char* LibraryName; RESOURCE_TABLE* table; - FILE *hresfile; + FILE *hresfile = NULL; char buffer[2000]; char *src, *dest; - char *dbfile; + char *dbfile = NULL; + int rc = 0; /* Creating database */ dbfile = (char *) malloc (strlen(DATABASE_NAME) + 20); + + if (dbfile==NULL) { + printf("Out of memory\n"); + rc = 1; + goto done; + } + strcpy(dbfile, DATABASE_NAME); strcat(dbfile, ".properties"); @@ -174,7 +182,8 @@ XP_MakeStringProperties(void) if (hresfile==NULL) { printf("Error creating properties file %s\n",DATABASE_NAME); - return 1; + rc = 1; + goto done; } j = 0; @@ -213,8 +222,10 @@ XP_MakeStringProperties(void) } } - fclose(hresfile); - return 0; +done: + if (hresfile) fclose(hresfile); + if (dbfile) free(dbfile); + return rc; } |