author | erik <erik> | 2007-01-19 01:20:57 (UTC) |
---|---|---|
committer | erik <erik> | 2007-01-19 01:20:57 (UTC) |
commit | f60301bab1f8aa3693089036a3791a01ae6f9db8 (patch) (unidiff) | |
tree | 876aef9930a5f85762bcc17e0310921617a568da /core | |
parent | 32343107b30904806d02672955c57ed53d39fe79 (diff) | |
download | opie-f60301bab1f8aa3693089036a3791a01ae6f9db8.zip opie-f60301bab1f8aa3693089036a3791a01ae6f9db8.tar.gz opie-f60301bab1f8aa3693089036a3791a01ae6f9db8.tar.bz2 |
core/opie-login/loginwindowimpl.cpp has a fix to properly free strings
that were dup'ed.
noncore/apps/opie-reader/Bkmks.cpp deletes a temporary pointer that
was not being properly disposed of.
-rw-r--r-- | core/opie-login/loginwindowimpl.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/core/opie-login/loginwindowimpl.cpp b/core/opie-login/loginwindowimpl.cpp index 547a9b3..b9a286d 100644 --- a/core/opie-login/loginwindowimpl.cpp +++ b/core/opie-login/loginwindowimpl.cpp | |||
@@ -204,56 +204,73 @@ public: | |||
204 | 204 | ||
205 | m_visible = false; | 205 | m_visible = false; |
206 | show ( ); | 206 | show ( ); |
207 | } | 207 | } |
208 | 208 | ||
209 | virtual void showEvent ( QShowEvent *e ) | 209 | virtual void showEvent ( QShowEvent *e ) |
210 | { | 210 | { |
211 | QLabel::showEvent ( e ); | 211 | QLabel::showEvent ( e ); |
212 | m_visible = true; | 212 | m_visible = true; |
213 | } | 213 | } |
214 | 214 | ||
215 | virtual void paintEvent ( QPaintEvent *e ) | 215 | virtual void paintEvent ( QPaintEvent *e ) |
216 | { | 216 | { |
217 | QLabel::paintEvent ( e ); | 217 | QLabel::paintEvent ( e ); |
218 | if ( m_visible ) | 218 | if ( m_visible ) |
219 | qApp-> quit ( ); | 219 | qApp-> quit ( ); |
220 | } | 220 | } |
221 | 221 | ||
222 | private: | 222 | private: |
223 | bool m_visible; | 223 | bool m_visible; |
224 | }; | 224 | }; |
225 | 225 | ||
226 | void LoginWindowImpl::login ( ) | 226 | void LoginWindowImpl::login ( ) |
227 | { | 227 | { |
228 | const char *user = ::strdup ( m_user-> currentText ( ). local8Bit ( )); | 228 | char *const user = ::strdup ( m_user-> currentText ( ). local8Bit ( )); |
229 | const char *pass = ::strdup ( m_password-> text ( ). local8Bit ( )); | 229 | char *pass = ::strdup ( m_password-> text ( ). local8Bit ( )); |
230 | 230 | ||
231 | if ( !user || !user [0] ) | 231 | if ( !user ) { |
232 | if ( pass ) | ||
233 | free( pass ); | ||
232 | return; | 234 | return; |
233 | if ( !pass ) | 235 | } |
236 | if ( !user [0] ) { | ||
237 | free( user ); | ||
238 | if ( pass ) | ||
239 | free( pass ); | ||
240 | return; | ||
241 | } | ||
242 | bool passwordIsEmpty = false; | ||
243 | if ( !pass ) { | ||
244 | passwordIsEmpty = true; | ||
234 | pass = ""; | 245 | pass = ""; |
246 | } | ||
235 | 247 | ||
236 | if ( lApp-> checkPassword ( user, pass )) { | 248 | if ( lApp-> checkPassword ( user, pass )) { |
249 | if ( !passwordIsEmpty ) | ||
250 | free(pass); | ||
237 | Config cfg ( "opie-login" ); | 251 | Config cfg ( "opie-login" ); |
238 | cfg. setGroup ( "General" ); | 252 | cfg. setGroup ( "General" ); |
239 | cfg. writeEntry ( "LastLogin", user ); | 253 | cfg. writeEntry ( "LastLogin", user ); |
240 | cfg. write ( ); | 254 | cfg. write ( ); |
241 | 255 | ||
242 | lApp-> setLoginAs ( user ); | 256 | lApp-> setLoginAs ( user ); |
243 | 257 | ||
244 | // Draw a big wait icon, the image can be altered in later revisions | 258 | // Draw a big wait icon, the image can be altered in later revisions |
245 | m_input-> hideInputMethod ( ); | 259 | m_input-> hideInputMethod ( ); |
246 | new WaitLogo ( ); | 260 | new WaitLogo ( ); |
247 | // WaitLogo::showEvent() calls qApp-> quit() | 261 | // WaitLogo::showEvent() calls qApp-> quit() |
248 | } | 262 | } |
249 | else { | 263 | else { |
250 | QMessageBox::warning ( this, tr( "Wrong password" ), tr( "The given password is incorrect." )); | 264 | QMessageBox::warning ( this, tr( "Wrong password" ), tr( "The given password is incorrect." )); |
251 | m_password-> clear ( ); | 265 | m_password-> clear ( ); |
266 | free( user ); | ||
267 | if ( !passwordIsEmpty ) | ||
268 | free( pass ); | ||
252 | } | 269 | } |
253 | } | 270 | } |
254 | 271 | ||
255 | void LoginWindowImpl::showPasswordDialog() { | 272 | void LoginWindowImpl::showPasswordDialog() { |
256 | PasswordDialogImpl dia( this ); | 273 | PasswordDialogImpl dia( this ); |
257 | dia.showMaximized(); | 274 | dia.showMaximized(); |
258 | dia.exec(); | 275 | dia.exec(); |
259 | } | 276 | } |