author | alwin <alwin> | 2004-03-10 21:21:32 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-10 21:21:32 (UTC) |
commit | a72855867dedd2b4c16f703fa104b5c6175ce484 (patch) (unidiff) | |
tree | ef38ab8d70f15ce8921cf8c587e77b1b460dfe88 | |
parent | dd34b866c0f3e5041696dd97cf356d86a8d6d212 (diff) | |
download | opie-a72855867dedd2b4c16f703fa104b5c6175ce484.zip opie-a72855867dedd2b4c16f703fa104b5c6175ce484.tar.gz opie-a72855867dedd2b4c16f703fa104b5c6175ce484.tar.bz2 |
fixed a problem with corrupted memory
-rw-r--r-- | noncore/net/mail/libmailwrapper/generatemail.cpp | 107 |
1 files changed, 60 insertions, 47 deletions
diff --git a/noncore/net/mail/libmailwrapper/generatemail.cpp b/noncore/net/mail/libmailwrapper/generatemail.cpp index 9272d0c..48fa02e 100644 --- a/noncore/net/mail/libmailwrapper/generatemail.cpp +++ b/noncore/net/mail/libmailwrapper/generatemail.cpp | |||
@@ -281,5 +281,6 @@ mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail | |||
281 | 281 | ||
282 | mailimf_fields *Generatemail::createImfFields(const Mail&mail ) { | 282 | mailimf_fields *Generatemail::createImfFields(const Mail&mail ) |
283 | mailimf_fields *fields; | 283 | { |
284 | mailimf_field *xmailer; | 284 | mailimf_fields *fields = NULL; |
285 | mailimf_field *xmailer = NULL; | ||
285 | mailimf_mailbox *sender=0,*fromBox=0; | 286 | mailimf_mailbox *sender=0,*fromBox=0; |
@@ -290,28 +291,36 @@ mailimf_fields *Generatemail::createImfFields(const Mail&mail ) { | |||
290 | int err; | 291 | int err; |
292 | int res = 1; | ||
291 | 293 | ||
292 | sender = newMailbox( mail.getName(), mail.getMail() ); | 294 | sender = newMailbox( mail.getName(), mail.getMail() ); |
293 | if ( sender == NULL ) | 295 | if ( sender == NULL ) { |
294 | goto err_free; | 296 | res = 0; |
297 | } | ||
295 | 298 | ||
299 | if (res) { | ||
296 | fromBox = newMailbox( mail.getName(), mail.getMail() ); | 300 | fromBox = newMailbox( mail.getName(), mail.getMail() ); |
297 | if ( fromBox == NULL ) | 301 | } |
298 | goto err_free_sender; | 302 | if ( fromBox == NULL ) { |
303 | res = 0; | ||
304 | } | ||
299 | 305 | ||
306 | if (res) { | ||
300 | from = mailimf_mailbox_list_new_empty(); | 307 | from = mailimf_mailbox_list_new_empty(); |
301 | if ( from == NULL ) | 308 | } |
302 | goto err_free_fromBox; | 309 | if ( from == NULL ) { |
310 | res = 0; | ||
311 | } | ||
303 | 312 | ||
313 | if (res && from) { | ||
304 | err = mailimf_mailbox_list_add( from, fromBox ); | 314 | err = mailimf_mailbox_list_add( from, fromBox ); |
305 | if ( err != MAILIMF_NO_ERROR ) | 315 | if ( err != MAILIMF_NO_ERROR ) { |
306 | goto err_free_from; | 316 | res = 0; |
307 | 317 | } | |
308 | to = parseAddresses( mail.getTo() ); | 318 | } |
309 | if ( to == NULL ) | ||
310 | goto err_free_from; | ||
311 | 319 | ||
312 | cc = parseAddresses( mail.getCC() ); | 320 | if (res) to = parseAddresses( mail.getTo() ); |
313 | bcc = parseAddresses( mail.getBCC() ); | 321 | if (res) cc = parseAddresses( mail.getCC() ); |
314 | reply = parseAddresses( mail.getReply() ); | 322 | if (res) bcc = parseAddresses( mail.getBCC() ); |
323 | if (res) reply = parseAddresses( mail.getReply() ); | ||
315 | 324 | ||
316 | if (mail.Inreply().count()>0) { | 325 | if (res && mail.Inreply().count()>0) { |
317 | in_reply_to = clist_new(); | 326 | in_reply_to = clist_new(); |
@@ -341,25 +350,29 @@ mailimf_fields *Generatemail::createImfFields(const Mail&mail ) { | |||
341 | 350 | ||
351 | if (res) { | ||
342 | fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, | 352 | fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, |
343 | in_reply_to, NULL, subject ); | 353 | in_reply_to, NULL, subject ); |
344 | if ( fields == NULL ) | 354 | if ( fields == NULL ) { |
345 | goto err_free_reply; | 355 | qDebug("Error creating mailimf fields"); |
346 | 356 | res = 0; | |
347 | xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), | 357 | } |
358 | } | ||
359 | if (res) xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), | ||
348 | strdup( USER_AGENT ) ); | 360 | strdup( USER_AGENT ) ); |
349 | if ( xmailer == NULL ) | 361 | if ( xmailer == NULL ) { |
350 | goto err_free_fields; | 362 | res = 0; |
351 | 363 | } else { | |
352 | err = mailimf_fields_add( fields, xmailer ); | 364 | err = mailimf_fields_add( fields, xmailer ); |
353 | if ( err != MAILIMF_NO_ERROR ) | 365 | if ( err != MAILIMF_NO_ERROR ) { |
354 | goto err_free_xmailer; | 366 | res = 0; |
355 | 367 | } | |
356 | return fields; // Success :) | 368 | } |
357 | 369 | if (!res ) { | |
358 | err_free_xmailer: | 370 | if (xmailer) { |
359 | if (xmailer) | ||
360 | mailimf_field_free( xmailer ); | 371 | mailimf_field_free( xmailer ); |
361 | err_free_fields: | 372 | xmailer = NULL; |
362 | if (fields) | 373 | } |
374 | if (fields) { | ||
363 | mailimf_fields_free( fields ); | 375 | mailimf_fields_free( fields ); |
364 | err_free_reply: | 376 | fields = NULL; |
377 | } else { | ||
365 | if (reply) | 378 | if (reply) |
@@ -372,16 +385,16 @@ err_free_reply: | |||
372 | mailimf_address_list_free( to ); | 385 | mailimf_address_list_free( to ); |
373 | err_free_from: | 386 | if (fromBox) { |
374 | if (from) | ||
375 | mailimf_mailbox_list_free( from ); | ||
376 | err_free_fromBox: | ||
377 | mailimf_mailbox_free( fromBox ); | 387 | mailimf_mailbox_free( fromBox ); |
378 | err_free_sender: | 388 | } else if (from) { |
379 | if (sender) | 389 | mailimf_mailbox_list_free( from ); |
390 | } | ||
391 | if (sender) { | ||
380 | mailimf_mailbox_free( sender ); | 392 | mailimf_mailbox_free( sender ); |
381 | err_free: | 393 | } |
382 | if (subject) | 394 | if (subject) { |
383 | free( subject ); | 395 | free( subject ); |
384 | qDebug( "createImfFields - error" ); | 396 | } |
385 | 397 | } | |
386 | return NULL; // Error :( | 398 | } |
399 | return fields; | ||
387 | } | 400 | } |