To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=67614
Issue #|67614
Summary|coverity 409: Leak of resources in case of an error
Component|udk
Version|680m177
Platform|All
URL|
OS/Version|All
Status|NEW
Status whiteboard|
Keywords|
Resolution|
Issue type|PATCH
Priority|P3
Subcomponent|code
Assigned to|kr
Reported by|kendy
------- Additional comments from [EMAIL PROTECTED] Thu Jul 20 07:06:51 -0700
2006 -------
codemaker/source/codemaker/global.cxx:
191 sal_Bool checkFileContent(const OString& targetFileName, const OString&
tmpFileName)
192 {
193 FILE *target = fopen(targetFileName.getStr(), "r");
Event alloc_fn: Called allocation function "fopen"
Event var_assign: Assigned variable "tmp" to storage returned from "fopen"
Also see events: [var_assign][leaked_storage]
194 FILE *tmp = fopen(tmpFileName.getStr(), "r");
195 sal_Bool bFindChanges = sal_False;
196
At conditional (1): "target != 0" taking false path
197 if (target != NULL && tmp != NULL)
198 {
199 sal_Char buffer1[1024+1];
200 sal_Char buffer2[1024+1];
201 sal_Int32 n1 = 0;
202 sal_Int32 n2 = 0;
203
204 while ( !bFindChanges && !feof(target) && !feof(tmp))
205 {
206 n1 = fread(buffer1, sizeof(sal_Char), 1024, target);
207 n2 = fread(buffer2, sizeof(sal_Char), 1024, tmp);
208
209 if ( n1 != n2 )
210 bFindChanges = sal_True;
211 else
212 if ( rtl_compareMemory(buffer1, buffer2, n2) != 0 )
213 bFindChanges = sal_True;
214 }
215
216 fclose(target);
217 fclose(tmp);
218 }
219
Event leaked_storage: Returned without freeing storage "tmp"
Also see events: [alloc_fn][var_assign]
220 return bFindChanges;
221 }
When just one of the 'tmp', or 'target' is NULL, the other is not freed.
Proposed fix:
--- global.cxx 20 Jun 2006 02:23:12 -0000 1.26
+++ global.cxx 20 Jul 2006 14:04:23 -0000
@@ -212,10 +212,12 @@ sal_Bool checkFileContent(const OString&
if ( rtl_compareMemory(buffer1, buffer2, n2) != 0 )
bFindChanges = sal_True;
}
+ }
+ if ( target )
fclose(target);
+ if ( tmp )
fclose(tmp);
- }
return bFindChanges;
}
---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]