From: Peter Howkins Date: Mon, 2 Apr 2018 19:29:28 +0000 (+0100) Subject: dtmail: resolve 'deference before null check' errors related to if(!NULL) checks... X-Git-Tag: 2.2.4a~137 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=0b38496bd8d11d3c15b6ceb3b890fcae502821e8;p=oweals%2Fcde.git dtmail: resolve 'deference before null check' errors related to if(!NULL) checks around free() calls --- diff --git a/cde/programs/dtmail/dtmail/AliasListUiItem.C b/cde/programs/dtmail/dtmail/AliasListUiItem.C index da054c8c..b7b254c2 100644 --- a/cde/programs/dtmail/dtmail/AliasListUiItem.C +++ b/cde/programs/dtmail/dtmail/AliasListUiItem.C @@ -217,8 +217,7 @@ void AliasListUiItem::writeFromSourceToUi() for (i = 0; i < list_len; i++) list_items->append(prop_pairs[i]); - if (NULL != prop_pairs) - XtFree((char*) prop_pairs); + XtFree((char*) prop_pairs); } for (i = 0; i < list_len; i++) diff --git a/cde/programs/dtmail/dtmail/AlternatesListUiItem.C b/cde/programs/dtmail/dtmail/AlternatesListUiItem.C index 3745f769..6d7b334f 100644 --- a/cde/programs/dtmail/dtmail/AlternatesListUiItem.C +++ b/cde/programs/dtmail/dtmail/AlternatesListUiItem.C @@ -210,8 +210,7 @@ void AlternatesListUiItem::writeFromSourceToUi() delete char_list; - if(list_str != NULL) - free((void *)list_str); + free((void *)list_str); if(buf != NULL) free((void *)buf); diff --git a/cde/programs/dtmail/dtmail/AntiCheckBoxUiItem.C b/cde/programs/dtmail/dtmail/AntiCheckBoxUiItem.C index 0a706677..ab36078c 100644 --- a/cde/programs/dtmail/dtmail/AntiCheckBoxUiItem.C +++ b/cde/programs/dtmail/dtmail/AntiCheckBoxUiItem.C @@ -94,13 +94,12 @@ void AntiCheckBoxUiItem::writeFromSourceToUi() // // This assumes that a non-null value means that the // value is set and that a non-null means turn on the CB - if (strcmp(value, "f") == 0) + if (value && strcmp(value, "f") == 0) options_checkbox_set_value(w, TRUE, this->dirty_bit); else if (value == NULL || strcmp(value, "") == 0) options_checkbox_set_value(w, FALSE, this->dirty_bit); - if (value != NULL) - free((void*) value); + free(value); } diff --git a/cde/programs/dtmail/dtmail/CheckBoxUiItem.C b/cde/programs/dtmail/dtmail/CheckBoxUiItem.C index 468a41bc..c6053021 100644 --- a/cde/programs/dtmail/dtmail/CheckBoxUiItem.C +++ b/cde/programs/dtmail/dtmail/CheckBoxUiItem.C @@ -97,8 +97,7 @@ void CheckBoxUiItem::writeFromSourceToUi() else if (NULL == value || strcmp(value, "f") == 0) options_checkbox_set_value(w, FALSE, this->dirty_bit); - if (value != NULL) - free((void*) value); + free((void*) value); } diff --git a/cde/programs/dtmail/dtmail/CheckForMailUiItem.C b/cde/programs/dtmail/dtmail/CheckForMailUiItem.C index 8441d5c5..59397c3a 100644 --- a/cde/programs/dtmail/dtmail/CheckForMailUiItem.C +++ b/cde/programs/dtmail/dtmail/CheckForMailUiItem.C @@ -115,5 +115,5 @@ void CheckForMailUiItem::writeFromSourceToUi() options_spinbox_set_value(w, atoi(value), this->dirty_bit); _valueChanged = FALSE; - if (NULL != value) free((void*) value); + free((void*) value); } diff --git a/cde/programs/dtmail/dtmail/DmxMessage.C b/cde/programs/dtmail/dtmail/DmxMessage.C index 5b6dafc9..0c6ed6e6 100644 --- a/cde/programs/dtmail/dtmail/DmxMessage.C +++ b/cde/programs/dtmail/dtmail/DmxMessage.C @@ -394,8 +394,7 @@ DmxMsg::display ( strcpy(v3_cs, "DEFAULT"); strcat(v3_cs, "."); strcat(v3_cs, ret); - if (ret) - free(ret); + free(ret); } // Get iconv from and to codeset and do conversion. diff --git a/cde/programs/dtmail/dtmail/DmxPrintJob.C b/cde/programs/dtmail/dtmail/DmxPrintJob.C index ad15d0ec..0b4d33ca 100644 --- a/cde/programs/dtmail/dtmail/DmxPrintJob.C +++ b/cde/programs/dtmail/dtmail/DmxPrintJob.C @@ -630,8 +630,7 @@ DmxPrintJob::loadOutputWidgets(void) _print_output->appendNewLine(); XtFree(buffer); - if (NULL != separator_string) - free((void*) separator_string); + free((void*) separator_string); break; } diff --git a/cde/programs/dtmail/dtmail/Editor.C b/cde/programs/dtmail/dtmail/Editor.C index c6536854..6dc80ced 100644 --- a/cde/programs/dtmail/dtmail/Editor.C +++ b/cde/programs/dtmail/dtmail/Editor.C @@ -435,8 +435,7 @@ Editor::update_display_from_props(void) mailrc->getValue(error, "toolcols", &value); if (!error.isSet()){ cols = (int) strtol(value, NULL, 10); - if (NULL != value) - free((void*) value); + free((void*) value); } else { /* * MB_CUR_MAX == 1 : SingleByteLanguage diff --git a/cde/programs/dtmail/dtmail/EncryptedTextFieldUiItem.C b/cde/programs/dtmail/dtmail/EncryptedTextFieldUiItem.C index b9177cd1..e2d79427 100644 --- a/cde/programs/dtmail/dtmail/EncryptedTextFieldUiItem.C +++ b/cde/programs/dtmail/dtmail/EncryptedTextFieldUiItem.C @@ -138,7 +138,7 @@ void EncryptedTextFieldUiItem::writeFromSourceToUi() _loading = DTM_TRUE; options_field_set_value(w, value, this->dirty_bit); - if (NULL != value) free((void*) value); + free((void*) value); _loading = DTM_FALSE; } diff --git a/cde/programs/dtmail/dtmail/Fonts.C b/cde/programs/dtmail/dtmail/Fonts.C index 9452114f..cf3d8c1a 100644 --- a/cde/programs/dtmail/dtmail/Fonts.C +++ b/cde/programs/dtmail/dtmail/Fonts.C @@ -101,8 +101,7 @@ get_font( do_break = True; } - if (fl_entry_font_tag != NULL) - XtFree((char*) fl_entry_font_tag); + XtFree((char*) fl_entry_font_tag); if (do_break) break; diff --git a/cde/programs/dtmail/dtmail/InboxTextFieldUiItem.C b/cde/programs/dtmail/dtmail/InboxTextFieldUiItem.C index 057d5544..9875d093 100644 --- a/cde/programs/dtmail/dtmail/InboxTextFieldUiItem.C +++ b/cde/programs/dtmail/dtmail/InboxTextFieldUiItem.C @@ -85,7 +85,7 @@ void InboxTextFieldUiItem::writeFromUiToSource() else prop_source->setValue(value); - if (NULL != mailspool_file) free((void*) mailspool_file); + free((void*) mailspool_file); } // Takes values in the UI and puts them into the source DB @@ -114,6 +114,6 @@ void InboxTextFieldUiItem::writeFromSourceToUi() else options_field_set_value(w, value, this->dirty_bit); - if (NULL != value) free((void*) value); + free((void*) value); if (NULL != mailspool_file) free((void*) mailspool_file); } diff --git a/cde/programs/dtmail/dtmail/MailRetrievalOptions.C b/cde/programs/dtmail/dtmail/MailRetrievalOptions.C index 41b881e5..1c7f6404 100644 --- a/cde/programs/dtmail/dtmail/MailRetrievalOptions.C +++ b/cde/programs/dtmail/dtmail/MailRetrievalOptions.C @@ -822,7 +822,7 @@ MailRetrievalOptions::isValidInboxPath(PropUiItem* pui, void* data) errmsg = NULL; if (inbox_path) free(inbox_path); - if (expanded_path) free(expanded_path); + free(expanded_path); return (char*) errmsg; } diff --git a/cde/programs/dtmail/dtmail/MoveMenuListUiItem.C b/cde/programs/dtmail/dtmail/MoveMenuListUiItem.C index 47556b26..02f6fe88 100644 --- a/cde/programs/dtmail/dtmail/MoveMenuListUiItem.C +++ b/cde/programs/dtmail/dtmail/MoveMenuListUiItem.C @@ -228,8 +228,7 @@ void MoveMenuListUiItem::writeFromSourceToUi() delete char_list; - if(list_str != NULL) - free((void*) list_str); + free((void*) list_str); if(buf != NULL) free((void *)buf); diff --git a/cde/programs/dtmail/dtmail/RoamApp.C b/cde/programs/dtmail/dtmail/RoamApp.C index 99f21bf3..88680d94 100644 --- a/cde/programs/dtmail/dtmail/RoamApp.C +++ b/cde/programs/dtmail/dtmail/RoamApp.C @@ -723,7 +723,7 @@ tooltalk_msg_handler( &file); } - if (str) free(str); + free(str); if (NULL == file) { diff --git a/cde/programs/dtmail/dtmail/RoamMenuWindow.C b/cde/programs/dtmail/dtmail/RoamMenuWindow.C index 446c89a5..c0b7357a 100644 --- a/cde/programs/dtmail/dtmail/RoamMenuWindow.C +++ b/cde/programs/dtmail/dtmail/RoamMenuWindow.C @@ -421,8 +421,7 @@ RoamMenuWindow::RoamMenuWindow (char *name) : MenuWindow ("dtmail", True) else _inbox = FALSE; - if (NULL != mail_file) - free((void*)mail_file); + free((void*)mail_file); _list = NULL; _genDialog = NULL; @@ -465,7 +464,7 @@ RoamMenuWindow::RoamMenuWindow (char *name) : MenuWindow ("dtmail", True) else _last_sorted_by = (SortBy) atoi(value); - if (NULL != value) free((void*) value); + free((void*) value); if (NULL != buffer) XtFree(buffer); } @@ -788,7 +787,7 @@ RoamMenuWindow::createWorkArea(Widget parent) int header_lines = (int) strtol(value, NULL, 10); _list->visibleItems(header_lines); - if (NULL != value) free((void*) value); + free((void*) value); XtAddCallback( _list->get_scrolling_list(), XmNhelpCallback, @@ -1863,8 +1862,7 @@ RoamMenuWindow::propsChanged(void) if (header_lines != _list->visibleItems()) _list->visibleItems(header_lines); - if (NULL != value) - free((void*) value); + free((void*) value); _list->checkDisplayProp(); _my_editor->textEditor()->update_display_from_props(); @@ -2788,7 +2786,7 @@ RoamMenuWindow::create_container_callback(void *client_data, char *selection) { RoamMenuWindow *obj = (RoamMenuWindow*) client_data; obj->create_new_container(selection); - if (NULL != selection) XtFree(selection); + XtFree(selection); } void @@ -5152,8 +5150,7 @@ RoamMenuWindow::addToCachedContainerList(char *filename) &mail_file); is_inbox = (0 == strcmp(mail_file, filename)); - if (NULL != mail_file) - free((void*) mail_file); + free((void*) mail_file); if (is_inbox) return; diff --git a/cde/programs/dtmail/dtmail/ScaleUiItem.C b/cde/programs/dtmail/dtmail/ScaleUiItem.C index 19b5f9b2..73a32c5d 100644 --- a/cde/programs/dtmail/dtmail/ScaleUiItem.C +++ b/cde/programs/dtmail/dtmail/ScaleUiItem.C @@ -85,6 +85,5 @@ void ScaleUiItem::writeFromSourceToUi() options_scale_set_value(w, value, this->dirty_bit); - if (NULL != value) - free((void*) value); + free((void*) value); } diff --git a/cde/programs/dtmail/dtmail/SendMsgDialog.C b/cde/programs/dtmail/dtmail/SendMsgDialog.C index 473853dc..310adfbf 100644 --- a/cde/programs/dtmail/dtmail/SendMsgDialog.C +++ b/cde/programs/dtmail/dtmail/SendMsgDialog.C @@ -915,9 +915,7 @@ SendMsgDialog::storeHeaders(DtMail::Message * input) else { env->removeHeader(error, hl->header); } - if (value) { - XtFree(value); - } + XtFree(value); } } @@ -1727,9 +1725,7 @@ SendMsgDialog::include_file_cb( void *client_data, char *selection ) { SendMsgDialog *obj = (SendMsgDialog *)client_data; obj->include_file(selection); - if (NULL != selection) - XtFree(selection); - + XtFree(selection); } void diff --git a/cde/programs/dtmail/dtmail/SpinBoxUiItem.C b/cde/programs/dtmail/dtmail/SpinBoxUiItem.C index 25a34c7a..94512b51 100644 --- a/cde/programs/dtmail/dtmail/SpinBoxUiItem.C +++ b/cde/programs/dtmail/dtmail/SpinBoxUiItem.C @@ -86,8 +86,7 @@ void SpinBoxUiItem::writeFromSourceToUi() options_spinbox_set_value(w, atoi(value), this->dirty_bit); - if (NULL != value) - free((void*) value); + free((void*) value); } diff --git a/cde/programs/dtmail/dtmail/WMSaveSession.C b/cde/programs/dtmail/dtmail/WMSaveSession.C index a0348e5f..e348cc52 100644 --- a/cde/programs/dtmail/dtmail/WMSaveSession.C +++ b/cde/programs/dtmail/dtmail/WMSaveSession.C @@ -181,8 +181,7 @@ RoamApp::openSessionFile(char *filename) LOG_FPRINTF(log, (log,"Opened session file: %s\n",pathname)); LOG_CLOSEFILEPTR(log); - if (pathname != NULL) - XtFree((char *)pathname); + XtFree((char *)pathname); } /* diff --git a/cde/programs/dtmail/dtmail/options_util.C b/cde/programs/dtmail/dtmail/options_util.C index b2bfd364..9cce108d 100644 --- a/cde/programs/dtmail/dtmail/options_util.C +++ b/cde/programs/dtmail/dtmail/options_util.C @@ -312,8 +312,8 @@ options_spinbox_modCB( cbs->doit = FALSE; XBell(dpy, 50); } - if (NULL != text) XtFree(text); - if (NULL != textvalue) XtFree(textvalue); + XtFree(text); + XtFree(textvalue); } void diff --git a/cde/programs/dtmail/dtmailpr/message.C b/cde/programs/dtmail/dtmailpr/message.C index a1cc32c8..314b34de 100644 --- a/cde/programs/dtmail/dtmailpr/message.C +++ b/cde/programs/dtmail/dtmailpr/message.C @@ -297,8 +297,7 @@ DmxMsg::display (void) strcpy(v3_cs, "DEFAULT"); strcat(v3_cs, "."); strcat(v3_cs, ret); - if (ret) - free(ret); + free(ret); } // Get iconv from and to codeset and do conversion. diff --git a/cde/programs/dtmail/libDtMail/Common/Session.C b/cde/programs/dtmail/libDtMail/Common/Session.C index 830a9972..b1b387cb 100644 --- a/cde/programs/dtmail/libDtMail/Common/Session.C +++ b/cde/programs/dtmail/libDtMail/Common/Session.C @@ -1597,8 +1597,7 @@ DtMail::Session::targetTagName(char *special) NULL, &ret_codeset); - if (ret_locale) - free(ret_locale); + free(ret_locale); if (ret_lang) free(ret_lang); if (ret_target) diff --git a/cde/programs/dtmail/libDtMail/RFC/MIMEBodyPart.C b/cde/programs/dtmail/libDtMail/RFC/MIMEBodyPart.C index 1e631140..f352cadf 100644 --- a/cde/programs/dtmail/libDtMail/RFC/MIMEBodyPart.C +++ b/cde/programs/dtmail/libDtMail/RFC/MIMEBodyPart.C @@ -382,8 +382,7 @@ MIMEBodyPart::getDtType(DtMailEnv & error) error.clear(); if (type) DtDtsFreeDataType(type); - if (mime_type) - free(mime_type); + free(mime_type); if (name) free(name); } @@ -510,7 +509,6 @@ MIMEBodyPart::loadBody(DtMailEnv & error) } } } - if ( cs ) free ( cs ); if ( from_cs ) free( from_cs ); diff --git a/cde/programs/dtmail/libDtMail/RFC/RFCMailBox.C b/cde/programs/dtmail/libDtMail/RFC/RFCMailBox.C index 0b140919..3b0b98e3 100644 --- a/cde/programs/dtmail/libDtMail/RFC/RFCMailBox.C +++ b/cde/programs/dtmail/libDtMail/RFC/RFCMailBox.C @@ -4963,7 +4963,7 @@ RFCMailBox::createMailRetrievalAgent(char *password) appendCB, (void*) this); if (NULL != _mra_server) _mra_server->set_password(_mra_serverpw); - if (NULL != protocol) free(protocol); + free(protocol); } else if (True == DtMailServer::get_mailrc_value( _session, DTMAS_INBOX, diff --git a/cde/programs/dtmail/libDtMail/RFC/RFCMailValues.C b/cde/programs/dtmail/libDtMail/RFC/RFCMailValues.C index 38d53ebf..23360212 100644 --- a/cde/programs/dtmail/libDtMail/RFC/RFCMailValues.C +++ b/cde/programs/dtmail/libDtMail/RFC/RFCMailValues.C @@ -170,8 +170,7 @@ decode1522(const char * enc_start, const char * max_end, char **output, DtMail:: free( from_cs ); if (NULL != to_cs) free ( to_cs ); - if (NULL != cs_name) - free(cs_name); + free(cs_name); return(enc_end); } diff --git a/cde/programs/dtmail/libDtMail/RFC/SunV3.C b/cde/programs/dtmail/libDtMail/RFC/SunV3.C index f4a4c4bb..248048c8 100644 --- a/cde/programs/dtmail/libDtMail/RFC/SunV3.C +++ b/cde/programs/dtmail/libDtMail/RFC/SunV3.C @@ -375,14 +375,12 @@ SunV3::formatBodies(DtMailEnv & error, delete [] cbuf; delete rd; } - if (bp_contents) { - free(bp_contents); - bp_contents = NULL; - } - if (name) { - free(name); - name = NULL; - } + + free(bp_contents); + bp_contents = NULL; + + free(name); + name = NULL; } } diff --git a/cde/programs/dtmail/libDtMail/RFC/V3BodyPart.C b/cde/programs/dtmail/libDtMail/RFC/V3BodyPart.C index 0d4fa1ba..425f640a 100644 --- a/cde/programs/dtmail/libDtMail/RFC/V3BodyPart.C +++ b/cde/programs/dtmail/libDtMail/RFC/V3BodyPart.C @@ -590,8 +590,7 @@ V3BodyPart::loadBody(DtMailEnv &) strcpy(cs, "DEFAULT"); strcat(cs, "."); strcat(cs, ret); - if ( ret ) - free( ret ); + free( ret ); } } // If cstmp is NULL