diff options
| author | Endi S. Dewata <edewata@redhat.com> | 2010-07-18 17:27:33 -0500 |
|---|---|---|
| committer | Noriko Hosoi <nhosoi@redhat.com> | 2010-08-20 13:04:42 -0700 |
| commit | 759378748cb944dbfbc90da867d27d170a20d8ee (patch) | |
| tree | bfc81372553ebd0a15f7c881b14a6c30693f286c | |
| parent | 54ec43e2c88e2adc4908a46ebf8770b1b134161e (diff) | |
| download | ds-759378748cb944dbfbc90da867d27d170a20d8ee.tar.gz ds-759378748cb944dbfbc90da867d27d170a20d8ee.tar.xz ds-759378748cb944dbfbc90da867d27d170a20d8ee.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 12115
description: Fixed resource leaks in readObject().
| -rw-r--r-- | ldap/servers/slapd/tools/ldclt/parser.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/ldap/servers/slapd/tools/ldclt/parser.c b/ldap/servers/slapd/tools/ldclt/parser.c index 0bd0a150..a02f30db 100644 --- a/ldap/servers/slapd/tools/ldclt/parser.c +++ b/ldap/servers/slapd/tools/ldclt/parser.c @@ -570,6 +570,7 @@ readObject ( { FILE *ifile; /* The file that contains the object to read */ char line[MAX_FILTER]; /* To read ifile */ + int rc = 0; /* * Open the file @@ -579,7 +580,8 @@ readObject ( { perror (obj->fname); fprintf (stderr, "Error: cannot open file \"%s\"\n", obj->fname); - return (-1); + rc = -1; + goto done; } /* @@ -590,18 +592,21 @@ readObject ( { if ((strlen (line) > 0) && (line[strlen(line)-1]=='\n')) line[strlen(line)-1] = '\0'; - if (parseLine (line, obj->fname, obj) < 0) - return (-1); + if (parseLine (line, obj->fname, obj) < 0) { + rc = -1; + goto done; + } } +done: /* * Do not forget to close the file ! */ - if (fclose (ifile) != 0) + if (ifile && fclose (ifile) != 0) { perror (obj->fname); fprintf (stderr, "Error: cannot fclose file \"%s\"\n", obj->fname); - return (-1); + rc = -1; } /* @@ -610,9 +615,9 @@ readObject ( if (obj->attribsNb == 0) { fprintf (stderr, "Error: no object found in \"%s\"\n", obj->fname); - return (-1); + rc = -1; } - return (0); + return rc; } |
