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 | |
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 | ||||
-rw-r--r-- | noncore/apps/opie-reader/Bkmks.cpp | 1 |
2 files changed, 22 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 | |||
@@ -164,96 +164,113 @@ void LoginWindowImpl::toggleEchoMode ( bool t ) | |||
164 | m_password-> setEchoMode ( t ? QLineEdit::Normal : QLineEdit::Password ); | 164 | m_password-> setEchoMode ( t ? QLineEdit::Normal : QLineEdit::Password ); |
165 | } | 165 | } |
166 | 166 | ||
167 | void LoginWindowImpl::showIM ( ) | 167 | void LoginWindowImpl::showIM ( ) |
168 | { | 168 | { |
169 | m_input-> showInputMethod ( ); | 169 | m_input-> showInputMethod ( ); |
170 | } | 170 | } |
171 | 171 | ||
172 | void LoginWindowImpl::restart ( ) | 172 | void LoginWindowImpl::restart ( ) |
173 | { | 173 | { |
174 | qApp-> quit ( ); | 174 | qApp-> quit ( ); |
175 | } | 175 | } |
176 | 176 | ||
177 | void LoginWindowImpl::quit ( ) | 177 | void LoginWindowImpl::quit ( ) |
178 | { | 178 | { |
179 | lApp-> quitToConsole ( ); | 179 | lApp-> quitToConsole ( ); |
180 | } | 180 | } |
181 | 181 | ||
182 | void LoginWindowImpl::suspend ( ) | 182 | void LoginWindowImpl::suspend ( ) |
183 | { | 183 | { |
184 | ODevice::inst ( )-> suspend ( ); | 184 | ODevice::inst ( )-> suspend ( ); |
185 | 185 | ||
186 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 186 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
187 | e << -3; // Force on | 187 | e << -3; // Force on |
188 | } | 188 | } |
189 | 189 | ||
190 | void LoginWindowImpl::backlight ( ) | 190 | void LoginWindowImpl::backlight ( ) |
191 | { | 191 | { |
192 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 192 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
193 | e << -2; // toggle | 193 | e << -2; // toggle |
194 | } | 194 | } |
195 | 195 | ||
196 | class WaitLogo : public QLabel { | 196 | class WaitLogo : public QLabel { |
197 | public: | 197 | public: |
198 | WaitLogo ( ) : QLabel ( 0, "wait hack!", WStyle_Customize | WStyle_NoBorder | WStyle_Tool ) | 198 | WaitLogo ( ) : QLabel ( 0, "wait hack!", WStyle_Customize | WStyle_NoBorder | WStyle_Tool ) |
199 | { | 199 | { |
200 | setPixmap( Opie::Core::OResource::loadPixmap( "launcher/new_wait" ) ); | 200 | setPixmap( Opie::Core::OResource::loadPixmap( "launcher/new_wait" ) ); |
201 | setAlignment ( AlignCenter ); | 201 | setAlignment ( AlignCenter ); |
202 | move ( 0, 0 ); | 202 | move ( 0, 0 ); |
203 | resize ( qApp-> desktop ( )-> width ( ), qApp-> desktop ( )-> height ( )); | 203 | resize ( qApp-> desktop ( )-> width ( ), qApp-> desktop ( )-> height ( )); |
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 | } |
diff --git a/noncore/apps/opie-reader/Bkmks.cpp b/noncore/apps/opie-reader/Bkmks.cpp index 28f6318..00141a3 100644 --- a/noncore/apps/opie-reader/Bkmks.cpp +++ b/noncore/apps/opie-reader/Bkmks.cpp | |||
@@ -258,128 +258,129 @@ CList<Bkmk>* BkmkFile::readall() | |||
258 | } | 258 | } |
259 | isUpgraded = true; | 259 | isUpgraded = true; |
260 | } | 260 | } |
261 | else | 261 | else |
262 | { | 262 | { |
263 | switch(newmagic & 0xff) | 263 | switch(newmagic & 0xff) |
264 | { | 264 | { |
265 | case 7: | 265 | case 7: |
266 | isUpgraded = false; | 266 | isUpgraded = false; |
267 | bl = readall00(read07); | 267 | bl = readall00(read07); |
268 | // qDebug("Correct version!"); | 268 | // qDebug("Correct version!"); |
269 | break; | 269 | break; |
270 | case 6: | 270 | case 6: |
271 | isUpgraded = true; | 271 | isUpgraded = true; |
272 | bl = readall00(read06); | 272 | bl = readall00(read06); |
273 | // qDebug("Correct version!"); | 273 | // qDebug("Correct version!"); |
274 | break; | 274 | break; |
275 | case 5: | 275 | case 5: |
276 | isUpgraded = true; | 276 | isUpgraded = true; |
277 | bl = readall00(read05); | 277 | bl = readall00(read05); |
278 | // qDebug("Known version!"); | 278 | // qDebug("Known version!"); |
279 | break; | 279 | break; |
280 | default: | 280 | default: |
281 | // qDebug("Unknown version!"); | 281 | // qDebug("Unknown version!"); |
282 | isUpgraded = true; | 282 | isUpgraded = true; |
283 | bl = readall00(read05); | 283 | bl = readall00(read05); |
284 | } | 284 | } |
285 | } | 285 | } |
286 | } | 286 | } |
287 | return bl; | 287 | return bl; |
288 | } | 288 | } |
289 | 289 | ||
290 | CList<Bkmk>* BkmkFile::readall00(Bkmk* (*readfn)(BkmkFile*, FILE*)) | 290 | CList<Bkmk>* BkmkFile::readall00(Bkmk* (*readfn)(BkmkFile*, FILE*)) |
291 | { | 291 | { |
292 | CList<Bkmk>* bl = new CList<Bkmk>; | 292 | CList<Bkmk>* bl = new CList<Bkmk>; |
293 | while (1) | 293 | while (1) |
294 | { | 294 | { |
295 | Bkmk* b = (*readfn)(this, f); | 295 | Bkmk* b = (*readfn)(this, f); |
296 | if (b == NULL) break; | 296 | if (b == NULL) break; |
297 | bl->push_back(*b); | 297 | bl->push_back(*b); |
298 | delete b; | 298 | delete b; |
299 | } | 299 | } |
300 | return bl; | 300 | return bl; |
301 | } | 301 | } |
302 | 302 | ||
303 | Bkmk* BkmkFile::read03(BkmkFile* /*_this*/, FILE* f) | 303 | Bkmk* BkmkFile::read03(BkmkFile* /*_this*/, FILE* f) |
304 | { | 304 | { |
305 | Bkmk* b = NULL; | 305 | Bkmk* b = NULL; |
306 | if (f != NULL) | 306 | if (f != NULL) |
307 | { | 307 | { |
308 | unsigned short ln; | 308 | unsigned short ln; |
309 | if (fread(&ln,sizeof(ln),1,f) == 1) | 309 | if (fread(&ln,sizeof(ln),1,f) == 1) |
310 | { | 310 | { |
311 | tchar* name = new tchar[ln+1]; | 311 | tchar* name = new tchar[ln+1]; |
312 | fread(name,sizeof(tchar),ln,f); | 312 | fread(name,sizeof(tchar),ln,f); |
313 | name[ln] = 0; | 313 | name[ln] = 0; |
314 | 314 | ||
315 | ln = 0; | 315 | ln = 0; |
316 | tchar* anno = new tchar[ln+1]; | 316 | tchar* anno = new tchar[ln+1]; |
317 | anno[ln] = 0; | 317 | anno[ln] = 0; |
318 | 318 | ||
319 | unsigned int pos; | 319 | unsigned int pos; |
320 | fread(&pos,sizeof(pos),1,f); | 320 | fread(&pos,sizeof(pos),1,f); |
321 | b = new Bkmk(name,anno,pos); | 321 | b = new Bkmk(name,anno,pos); |
322 | delete [] anno; | ||
322 | } | 323 | } |
323 | } | 324 | } |
324 | return b; | 325 | return b; |
325 | } | 326 | } |
326 | 327 | ||
327 | Bkmk* BkmkFile::read05(BkmkFile* /*_this*/, FILE* f) | 328 | Bkmk* BkmkFile::read05(BkmkFile* /*_this*/, FILE* f) |
328 | { | 329 | { |
329 | Bkmk* b = NULL; | 330 | Bkmk* b = NULL; |
330 | if (f != NULL) | 331 | if (f != NULL) |
331 | { | 332 | { |
332 | unsigned short ln; | 333 | unsigned short ln; |
333 | if (fread(&ln,sizeof(ln),1,f) == 1) | 334 | if (fread(&ln,sizeof(ln),1,f) == 1) |
334 | { | 335 | { |
335 | tchar* nm = new tchar[ln+1]; | 336 | tchar* nm = new tchar[ln+1]; |
336 | fread(nm,sizeof(tchar),ln,f); | 337 | fread(nm,sizeof(tchar),ln,f); |
337 | nm[ln] = 0; | 338 | nm[ln] = 0; |
338 | fread(&ln,sizeof(ln),1,f); | 339 | fread(&ln,sizeof(ln),1,f); |
339 | tchar* anno = new tchar[ln+1]; | 340 | tchar* anno = new tchar[ln+1]; |
340 | if (ln > 0) fread(anno,sizeof(tchar),ln,f); | 341 | if (ln > 0) fread(anno,sizeof(tchar),ln,f); |
341 | anno[ln] = 0; | 342 | anno[ln] = 0; |
342 | unsigned int pos; | 343 | unsigned int pos; |
343 | fread(&pos,sizeof(pos),1,f); | 344 | fread(&pos,sizeof(pos),1,f); |
344 | b = new Bkmk(nm,anno,pos); | 345 | b = new Bkmk(nm,anno,pos); |
345 | } | 346 | } |
346 | } | 347 | } |
347 | return b; | 348 | return b; |
348 | } | 349 | } |
349 | 350 | ||
350 | Bkmk* BkmkFile::read06(BkmkFile* /*_this*/, FILE* f) | 351 | Bkmk* BkmkFile::read06(BkmkFile* /*_this*/, FILE* f) |
351 | { | 352 | { |
352 | Bkmk* b = NULL; | 353 | Bkmk* b = NULL; |
353 | if (f != NULL) | 354 | if (f != NULL) |
354 | { | 355 | { |
355 | unsigned short ln; | 356 | unsigned short ln; |
356 | if (fread(&ln,sizeof(ln),1,f) == 1) | 357 | if (fread(&ln,sizeof(ln),1,f) == 1) |
357 | { | 358 | { |
358 | b = new Bkmk; | 359 | b = new Bkmk; |
359 | b->m_namelen = ln; | 360 | b->m_namelen = ln; |
360 | b->m_name = new unsigned char[b->m_namelen]; | 361 | b->m_name = new unsigned char[b->m_namelen]; |
361 | fread(b->m_name,1,b->m_namelen,f); | 362 | fread(b->m_name,1,b->m_namelen,f); |
362 | 363 | ||
363 | fread(&(b->m_annolen),sizeof(b->m_annolen),1,f); | 364 | fread(&(b->m_annolen),sizeof(b->m_annolen),1,f); |
364 | if (b->m_annolen > 0) | 365 | if (b->m_annolen > 0) |
365 | { | 366 | { |
366 | b->m_anno = new unsigned char[b->m_annolen]; | 367 | b->m_anno = new unsigned char[b->m_annolen]; |
367 | fread(b->m_anno,1,b->m_annolen,f); | 368 | fread(b->m_anno,1,b->m_annolen,f); |
368 | } | 369 | } |
369 | fread(&(b->m_position),sizeof(b->m_position),1,f); | 370 | fread(&(b->m_position),sizeof(b->m_position),1,f); |
370 | b->m_position2 = b->m_position+b->m_namelen-1; | 371 | b->m_position2 = b->m_position+b->m_namelen-1; |
371 | b->m_red = b->m_green = b->m_blue = 127; | 372 | b->m_red = b->m_green = b->m_blue = 127; |
372 | b->m_level = 0; | 373 | b->m_level = 0; |
373 | } | 374 | } |
374 | } | 375 | } |
375 | return b; | 376 | return b; |
376 | } | 377 | } |
377 | 378 | ||
378 | Bkmk* BkmkFile::read07(BkmkFile* _this, FILE* f) | 379 | Bkmk* BkmkFile::read07(BkmkFile* _this, FILE* f) |
379 | { | 380 | { |
380 | Bkmk* b = NULL; | 381 | Bkmk* b = NULL; |
381 | if (f != NULL) | 382 | if (f != NULL) |
382 | { | 383 | { |
383 | unsigned short ln; | 384 | unsigned short ln; |
384 | if (fread(&ln,sizeof(ln),1,f) == 1) | 385 | if (fread(&ln,sizeof(ln),1,f) == 1) |
385 | { | 386 | { |