Bug 52918 - Crash while closing the history file
Summary: Crash while closing the history file
Status: RESOLVED FIXED
Alias: None
Product: kopete
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Kopete Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-01-12 20:34 UTC by bjoernv
Modified: 2003-01-12 21:57 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bjoernv 2003-01-12 20:34:53 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
Compiler:          gcc 3.2 
OS:          Linux

If I want to see the history file from a user
which doesn't already have a history file,
Kopete crashed. 

The problem can be found in libkopete/ui/kopetehistorywidget.cpp

line 450-456:
		//Check if thie file exists
		FILE *f = fopen(QFile::encodeName(*it), "r");

		if (f == NULL)
		{
			// Oops, no file
		}

If the file doesn't exists, no error message is displayed.

line 504:
		fclose(f);

The problem is that fclose(f) is called, even if f==NULL. So fclose(f) crashes.
Comment 1 Andy Goossens 2003-01-12 21:57:22 UTC
Subject: kdenonbeta/kopete/libkopete/ui

CVS commit by goossens: 

close file only when it exists

heh, this was the same fix as my very first Kopete bugfix so many months ago...
brings back memories ;-)

you see: history repeats itself
(okay, coincidence it's related to a fix in the history dialog :-p )

CCMAIL: 52918-close@bugs.kde.org


  M +5 -4      kopetehistorywidget.cpp   1.19


--- kdenonbeta/kopete/libkopete/ui/kopetehistorywidget.cpp  #1.18:1.19
@@ -500,7 +500,8 @@ int KopeteHistoryWidget::countMessages()
                                 }
                         }
-                }
                 
+                        // Close file only when it exists
                 fclose(f);
+                }
         }