From 2f634848ce5fd3ecd9971c2cb8d62c65c4d78d3e Mon Sep 17 00:00:00 2001 From: Peter Howkins Date: Mon, 23 Apr 2018 02:20:23 +0100 Subject: [PATCH] dtinfo: Fix coverity warning related to using delete not delete [] --- cde/programs/dtinfo/DtMmdb/StyleSheet/BitVector.C | 4 ++-- cde/programs/dtinfo/DtMmdb/StyleSheet/FeatureValue.C | 2 +- cde/programs/dtinfo/DtMmdb/api/info_lib.C | 4 ++-- cde/programs/dtinfo/DtMmdb/dti_cc/CC_String.h | 2 +- cde/programs/dtinfo/DtMmdb/dti_cc/CC_Tokenizer.h | 2 +- cde/programs/dtinfo/DtMmdb/dynhash/imp_die.C | 8 ++++---- cde/programs/dtinfo/DtMmdb/hmphf/buckets.C | 8 ++++---- cde/programs/dtinfo/DtMmdb/hmphf/mphf_funcs.C | 4 ++-- cde/programs/dtinfo/DtMmdb/hmphf/mphf_hash_table.C | 6 +++--- cde/programs/dtinfo/DtMmdb/hmphf/pattern.C | 2 +- cde/programs/dtinfo/DtMmdb/hmphf/sorter.C | 10 +++++----- cde/programs/dtinfo/DtMmdb/object/oid_list.C | 4 ++-- cde/programs/dtinfo/DtMmdb/oliasdb/c_api_bookcase.C | 2 +- cde/programs/dtinfo/DtMmdb/oliasdb/mmdb.C | 4 ++-- cde/programs/dtinfo/DtMmdb/oliasdb/user_base.C | 4 ++-- cde/programs/dtinfo/DtMmdb/schema/container_desc.C | 2 +- cde/programs/dtinfo/DtMmdb/schema/object_dict.C | 4 ++-- .../dtinfo/DtMmdb/schema/stored_object_desc.C | 4 ++-- cde/programs/dtinfo/DtMmdb/storage/chunks_index.C | 2 +- cde/programs/dtinfo/DtMmdb/storage/store_test.C | 2 +- cde/programs/dtinfo/DtMmdb/utility/ostring.C | 2 +- cde/programs/dtinfo/DtMmdb/utility/ostring.h | 2 +- cde/programs/dtinfo/DtMmdb/utility/randomize.C | 2 +- cde/programs/dtinfo/DtMmdb/utility/rw_lock.C | 2 +- .../dtinfo/dtinfo/src/Agents/NodeHistoryAgentMotif.C | 2 +- .../dtinfo/dtinfo/src/Agents/NodeWindowAgentMotif.C | 2 +- .../dtinfo/dtinfo/src/Agents/OutlineListViewMotif.C | 8 ++++---- cde/programs/dtinfo/dtinfo/src/Basic/BitField.C | 6 +++--- cde/programs/dtinfo/dtinfo/src/UAS/DtSR/TextParser.C | 2 +- .../dtinfo/dtinfogen/infolib/etc/BookTasks.C | 4 ++-- cde/programs/dtinfo/dtinfogen/infolib/etc/DataBase.C | 4 ++-- cde/programs/dtinfo/dtinfogen/infolib/etc/Dispatch.C | 2 +- cde/programs/dtinfo/dtinfogen/infolib/etc/MixedGen.C | 6 +++--- cde/programs/dtinfo/dtinfogen/infolib/etc/SGMLDefn.C | 12 ++++++------ .../dtinfo/dtinfogen/infolib/etc/StringList.C | 4 ++-- .../dtinfo/dtinfogen/infolib/etc/StyleTask.C | 2 +- cde/programs/dtinfo/dtinfogen/infolib/etc/TOCTask.C | 2 +- cde/programs/dtinfo/dtinfogen/infolib/etc/Task.C | 6 +++--- 38 files changed, 75 insertions(+), 75 deletions(-) diff --git a/cde/programs/dtinfo/DtMmdb/StyleSheet/BitVector.C b/cde/programs/dtinfo/DtMmdb/StyleSheet/BitVector.C index e2ff8d60..83d4f76e 100644 --- a/cde/programs/dtinfo/DtMmdb/StyleSheet/BitVector.C +++ b/cde/programs/dtinfo/DtMmdb/StyleSheet/BitVector.C @@ -57,14 +57,14 @@ void BitVector::setAllBitsTo(unsigned int initValue) BitVector::~BitVector() { - delete f_array; + delete [] f_array; delete f_positionArray; } void BitVector::setTo(BitVector& v) { if ( f_words != v.f_words ) { - delete f_array; + delete [] f_array; f_array = new unsigned int[v.f_words]; } f_bits = v.f_bits; diff --git a/cde/programs/dtinfo/DtMmdb/StyleSheet/FeatureValue.C b/cde/programs/dtinfo/DtMmdb/StyleSheet/FeatureValue.C index 412d0a90..c0625649 100644 --- a/cde/programs/dtinfo/DtMmdb/StyleSheet/FeatureValue.C +++ b/cde/programs/dtinfo/DtMmdb/StyleSheet/FeatureValue.C @@ -532,7 +532,7 @@ FeatureValueString::operator+(const FeatureValue& x) const newString[len1+len2] = 0; FeatureValueString *z = new FeatureValueString(newString); - delete newString; + delete [] newString; return z; } diff --git a/cde/programs/dtinfo/DtMmdb/api/info_lib.C b/cde/programs/dtinfo/DtMmdb/api/info_lib.C index 3b5fdc74..a5dffc18 100644 --- a/cde/programs/dtinfo/DtMmdb/api/info_lib.C +++ b/cde/programs/dtinfo/DtMmdb/api/info_lib.C @@ -215,8 +215,8 @@ f_bad_info_base_names(0), f_bad_info_base_paths(0), f_descriptor(des) memcpy(y, f_bad_info_base_paths, sizeof(charPtr)*f_bad_base_array_size); f_bad_base_array_size *= 2; - delete f_bad_info_base_names; - delete f_bad_info_base_paths; + delete [] f_bad_info_base_names; + delete [] f_bad_info_base_paths; f_bad_info_base_names = x; f_bad_info_base_paths = y; diff --git a/cde/programs/dtinfo/DtMmdb/dti_cc/CC_String.h b/cde/programs/dtinfo/DtMmdb/dti_cc/CC_String.h index 308e54fa..d48c919a 100644 --- a/cde/programs/dtinfo/DtMmdb/dti_cc/CC_String.h +++ b/cde/programs/dtinfo/DtMmdb/dti_cc/CC_String.h @@ -44,7 +44,7 @@ public: // functions f_string = NULL; } - virtual ~CC_String () { delete f_string; } + virtual ~CC_String () { delete [] f_string; } CC_Boolean isNull() const { return( f_string[0] == '\0' ); diff --git a/cde/programs/dtinfo/DtMmdb/dti_cc/CC_Tokenizer.h b/cde/programs/dtinfo/DtMmdb/dti_cc/CC_Tokenizer.h index 9dc584e9..489fde13 100644 --- a/cde/programs/dtinfo/DtMmdb/dti_cc/CC_Tokenizer.h +++ b/cde/programs/dtinfo/DtMmdb/dti_cc/CC_Tokenizer.h @@ -40,7 +40,7 @@ private: public: CC_Tokenizer(const CC_String & ); - ~CC_Tokenizer() { delete str_; } + ~CC_Tokenizer() { delete [] str_; } /* Here is an example to use the code diff --git a/cde/programs/dtinfo/DtMmdb/dynhash/imp_die.C b/cde/programs/dtinfo/DtMmdb/dynhash/imp_die.C index 04fb1783..fbbb7f05 100644 --- a/cde/programs/dtinfo/DtMmdb/dynhash/imp_die.C +++ b/cde/programs/dtinfo/DtMmdb/dynhash/imp_die.C @@ -100,8 +100,8 @@ imp_die::~imp_die() x = y ; } - delete hash_table; - delete bucket_array ; + delete [] hash_table; + delete [] bucket_array ; } //********************************************************** @@ -113,14 +113,14 @@ void imp_die::alloc_table(int new_H) { if ( bucket_array ) { for ( int i = 0; i appendString(list_ptr.loc, ptr, total_char_leng); } - delete ptr; + delete [] ptr; ok = true; diff --git a/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_bookcase.C b/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_bookcase.C index 60ff2ef9..2b8009fe 100644 --- a/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_bookcase.C +++ b/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_bookcase.C @@ -139,7 +139,7 @@ DtMmdbGetBookCaseByLocs(int infolib_descriptor, const char** locators, for ( int i=0; i index_id(); - delete bases; + delete [] bases; if (count_ptr) *count_ptr = count; diff --git a/cde/programs/dtinfo/DtMmdb/oliasdb/mmdb.C b/cde/programs/dtinfo/DtMmdb/oliasdb/mmdb.C index ed1c9f39..c11e2fef 100644 --- a/cde/programs/dtinfo/DtMmdb/oliasdb/mmdb.C +++ b/cde/programs/dtinfo/DtMmdb/oliasdb/mmdb.C @@ -72,8 +72,8 @@ OLIAS_DB::~OLIAS_DB() delete x; } - delete info_base_set_names; - delete info_base_list_names; + delete [] info_base_set_names; + delete [] info_base_list_names; } int OLIAS_DB::validInfoLibPath(const char* path) diff --git a/cde/programs/dtinfo/DtMmdb/oliasdb/user_base.C b/cde/programs/dtinfo/DtMmdb/oliasdb/user_base.C index 06aeb60a..3718324d 100644 --- a/cde/programs/dtinfo/DtMmdb/oliasdb/user_base.C +++ b/cde/programs/dtinfo/DtMmdb/oliasdb/user_base.C @@ -192,7 +192,7 @@ user_base::checking_status_t user_base::check_lock() ) { if ( ai_info ) { debug(cerr, ai_info); - delete ai_info; + delete [] ai_info; } return user_base::RLOCK_FAIL; } else @@ -220,7 +220,7 @@ user_base::checking_status_t user_base::check_lock() // return ok; // } - delete ai_info; + delete [] ai_info; } return user_base::WLOCK_FAIL; } else { diff --git a/cde/programs/dtinfo/DtMmdb/schema/container_desc.C b/cde/programs/dtinfo/DtMmdb/schema/container_desc.C index 4cecc660..640f3fa7 100644 --- a/cde/programs/dtinfo/DtMmdb/schema/container_desc.C +++ b/cde/programs/dtinfo/DtMmdb/schema/container_desc.C @@ -215,7 +215,7 @@ container_desc::init_index_array(object_dict& dict, index_array[pos] = tmp_index_array[ind]; } - delete tmp_index_array; + delete [] tmp_index_array; } ////////////////////////////////////////////////////////////////////// diff --git a/cde/programs/dtinfo/DtMmdb/schema/object_dict.C b/cde/programs/dtinfo/DtMmdb/schema/object_dict.C index 4c1c00b4..7a224954 100644 --- a/cde/programs/dtinfo/DtMmdb/schema/object_dict.C +++ b/cde/programs/dtinfo/DtMmdb/schema/object_dict.C @@ -156,7 +156,7 @@ desc* object_dict::init_a_base(char* db_path, char* db_name) //////////////// x = parse(orig); - delete buf; + delete [] buf; } @@ -268,7 +268,7 @@ desc* object_dict::init_a_base(char* define_desc_path, char* db_path, out.close(); - delete schema_buf; + delete [] schema_buf; return x; diff --git a/cde/programs/dtinfo/DtMmdb/schema/stored_object_desc.C b/cde/programs/dtinfo/DtMmdb/schema/stored_object_desc.C index 0ac74a78..d4fdca63 100644 --- a/cde/programs/dtinfo/DtMmdb/schema/stored_object_desc.C +++ b/cde/programs/dtinfo/DtMmdb/schema/stored_object_desc.C @@ -64,12 +64,12 @@ stored_object_desc::stored_object_desc(int class_code, const char* _type) stored_object_desc::~stored_object_desc() { - delete store_nm; + free(store_nm); } void stored_object_desc::set_store_nm(const char* str) { - delete store_nm; + free(store_nm); store_nm = strdup(str); } diff --git a/cde/programs/dtinfo/DtMmdb/storage/chunks_index.C b/cde/programs/dtinfo/DtMmdb/storage/chunks_index.C index 48cefeff..b852e32a 100644 --- a/cde/programs/dtinfo/DtMmdb/storage/chunks_index.C +++ b/cde/programs/dtinfo/DtMmdb/storage/chunks_index.C @@ -118,7 +118,7 @@ debug(cerr, vector[i] -> str_offset); binary_insert(vector, 0, vector_sz-1); - delete vector; + delete [] vector; } chunks_index::~chunks_index() diff --git a/cde/programs/dtinfo/DtMmdb/storage/store_test.C b/cde/programs/dtinfo/DtMmdb/storage/store_test.C index ce7314bb..f0a1bd49 100644 --- a/cde/programs/dtinfo/DtMmdb/storage/store_test.C +++ b/cde/programs/dtinfo/DtMmdb/storage/store_test.C @@ -93,7 +93,7 @@ void quit_store(page_storage** st, unsigned int ct) for ( unsigned int i=0; i= 0; i--) XmStringFree (table[i]); - delete table; + delete [] table; } diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/NodeWindowAgentMotif.C b/cde/programs/dtinfo/dtinfo/src/Agents/NodeWindowAgentMotif.C index 7686e88d..42f38f28 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/NodeWindowAgentMotif.C +++ b/cde/programs/dtinfo/dtinfo/src/Agents/NodeWindowAgentMotif.C @@ -4668,7 +4668,7 @@ NodeWindowAgent::create_canvas_mark(_DtCvHandle canvas, for (i = 0; i < markinfo.length(); i++) delete segs[i]; - delete segs ; + delete [] segs ; #ifdef BOOKMARK_DEBUG if (status == _DtCvSTATUS_BAD) diff --git a/cde/programs/dtinfo/dtinfo/src/Agents/OutlineListViewMotif.C b/cde/programs/dtinfo/dtinfo/src/Agents/OutlineListViewMotif.C index fdadc0a0..282032bf 100644 --- a/cde/programs/dtinfo/dtinfo/src/Agents/OutlineListViewMotif.C +++ b/cde/programs/dtinfo/dtinfo/src/Agents/OutlineListViewMotif.C @@ -712,8 +712,8 @@ OutlineListView::select_end (Widget w, XEvent *event, while (subcount > 0) if (selected_list[--subcount]) SelectPos (f_item_pos + subcount + 1, False); - delete table; - delete selected_list; + delete [] table; + delete [] selected_list; // Turn the wait cursor off if it was on. if (wait_state) @@ -787,7 +787,7 @@ OutlineListView::update_list(OutlineList *list, BitHandle handle) Set (args); delete table; - delete selected_list; + delete [] selected_list; } // ///////////////////////////////////////////////////////////////// @@ -1152,7 +1152,7 @@ OutlineListView::activate (WCallback *wcb) oe->level() + 1); AddItemsUnselected (table, subcount, lcs->item_position + 1); delete table; - delete sel_list; + delete [] sel_list; // Turn the wait cursor off if it was on. if (wait_state) diff --git a/cde/programs/dtinfo/dtinfo/src/Basic/BitField.C b/cde/programs/dtinfo/dtinfo/src/Basic/BitField.C index 5980e88d..9a5da925 100644 --- a/cde/programs/dtinfo/dtinfo/src/Basic/BitField.C +++ b/cde/programs/dtinfo/dtinfo/src/Basic/BitField.C @@ -103,7 +103,7 @@ BitField::BitField(unsigned long initial_bits) BitField::~BitField() { - delete f_words ; + delete [] f_words ; delete f_bits_in_use ; } @@ -123,7 +123,7 @@ BitField::check_allocation (unsigned long word) new_use[i] = f_bits_in_use[i]; } - delete f_words; + delete [] f_words; f_words = new_words; delete f_bits_in_use; f_bits_in_use = new_use; @@ -169,7 +169,7 @@ BitField::get_handle() new_words[f_num_words] = 0 ; new_use[f_num_words] = 0 ; - delete f_words ; + delete [] f_words ; f_words = new_words ; delete f_bits_in_use ; f_bits_in_use = new_use ; diff --git a/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/TextParser.C b/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/TextParser.C index bc333fbd..5935b65e 100644 --- a/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/TextParser.C +++ b/cde/programs/dtinfo/dtinfo/src/UAS/DtSR/TextParser.C @@ -233,7 +233,7 @@ StringParser::brute_force(const char* text_in, int n_of_pats, for (i = 0; i < npat; i++) free (pat_tbl[i]); - free (pat_tbl); + delete[] pat_tbl; if (caped_text) delete[] caped_text; diff --git a/cde/programs/dtinfo/dtinfogen/infolib/etc/BookTasks.C b/cde/programs/dtinfo/dtinfogen/infolib/etc/BookTasks.C index 7fffc32d..af59165e 100644 --- a/cde/programs/dtinfo/dtinfogen/infolib/etc/BookTasks.C +++ b/cde/programs/dtinfo/dtinfogen/infolib/etc/BookTasks.C @@ -550,7 +550,7 @@ void BookTask::write_record(void) snprintf(p, plen, "%s\t%s\t%s\t%s", name, loc, line, file); tablines.append(p); - delete p; + delete [] p; } const char *bk_title; @@ -600,7 +600,7 @@ void BookTask::reset() delete tabLines; tabLines = new StringList(); delete tabFiles; tabFiles = new StringList(); - delete tocLocator; tocLocator = NULL; + delete [] tocLocator; tocLocator = NULL; f_seq_no ++; diff --git a/cde/programs/dtinfo/dtinfogen/infolib/etc/DataBase.C b/cde/programs/dtinfo/dtinfogen/infolib/etc/DataBase.C index 192098cc..7b958087 100644 --- a/cde/programs/dtinfo/dtinfogen/infolib/etc/DataBase.C +++ b/cde/programs/dtinfo/dtinfogen/infolib/etc/DataBase.C @@ -154,7 +154,7 @@ DBTable::file(DB::Access access) throw(PosixError(errno, path)); } - delete path; + delete [] path; } } @@ -458,7 +458,7 @@ void DBCursor::string_field(FILE *fp, char **out, int *lenOut) if(lenOut) *lenOut = len; }else{ - delete str; + delete [] str; } } diff --git a/cde/programs/dtinfo/dtinfogen/infolib/etc/Dispatch.C b/cde/programs/dtinfo/dtinfogen/infolib/etc/Dispatch.C index eaf9cf0a..4e9bf5e0 100644 --- a/cde/programs/dtinfo/dtinfogen/infolib/etc/Dispatch.C +++ b/cde/programs/dtinfo/dtinfogen/infolib/etc/Dispatch.C @@ -192,7 +192,7 @@ Dispatch::file(const char *f) } search_path_table->replace_file_scope( dirname ); - delete dirname; + free(dirname); } } diff --git a/cde/programs/dtinfo/dtinfogen/infolib/etc/MixedGen.C b/cde/programs/dtinfo/dtinfogen/infolib/etc/MixedGen.C index ca527675..e877b9be 100644 --- a/cde/programs/dtinfo/dtinfogen/infolib/etc/MixedGen.C +++ b/cde/programs/dtinfo/dtinfogen/infolib/etc/MixedGen.C @@ -117,7 +117,7 @@ checkTocLink( const char *toc_file_name, } } - delete ToCFileName; + free(ToCFileName); if ( flag ) { throw(Unexpected("TOC validation failed\n")); @@ -618,7 +618,7 @@ lookahead( char * bufptr, char * currentgi, char * indpos) } // otherwise the next start tag is the same as the current one, so no // change to the indicator is needed. - delete nextgi; + free(nextgi); } return; } @@ -654,7 +654,7 @@ parse4last( char * bufptr ) } else { lookahead(bufptr, startname, indicator); } - delete startname; + free(startname); } else { // END TAG for ( ; *bufptr != '>'; bufptr++) { diff --git a/cde/programs/dtinfo/dtinfogen/infolib/etc/SGMLDefn.C b/cde/programs/dtinfo/dtinfogen/infolib/etc/SGMLDefn.C index 9f151882..4008f60a 100644 --- a/cde/programs/dtinfo/dtinfogen/infolib/etc/SGMLDefn.C +++ b/cde/programs/dtinfo/dtinfogen/infolib/etc/SGMLDefn.C @@ -49,16 +49,16 @@ SGMLDefn::SGMLDefn() SGMLDefn::~SGMLDefn() { - delete sys_id; - delete pub_id; - delete file_name; + delete [] sys_id; + delete [] pub_id; + delete [] file_name; } void SGMLDefn::store_sys_id( char *sid ) { if ( sid ) { - delete sys_id; + delete [] sys_id; int len = strlen(sid); sys_id = new char [len + 1]; @@ -72,7 +72,7 @@ void SGMLDefn::store_pub_id( char *pid ) { if ( pid ) { - delete pub_id; + delete [] pub_id; int len = strlen(pid); pub_id = new char [len + 1]; @@ -98,7 +98,7 @@ void SGMLDefn::store_file_name( char *fname ) { if ( fname ) { - delete file_name; + delete [] file_name; int len = strlen(fname); file_name = new char [len + 1]; diff --git a/cde/programs/dtinfo/dtinfogen/infolib/etc/StringList.C b/cde/programs/dtinfo/dtinfogen/infolib/etc/StringList.C index e7f8f834..078fbaae 100644 --- a/cde/programs/dtinfo/dtinfogen/infolib/etc/StringList.C +++ b/cde/programs/dtinfo/dtinfogen/infolib/etc/StringList.C @@ -37,7 +37,7 @@ StringList::StringList() StringList::~StringList() { reset(); - delete items; + delete [] items; } void StringList::grow(size_t total) @@ -47,7 +47,7 @@ void StringList::grow(size_t total) if(used > 0){ memcpy(born, items, used *sizeof(items[0])); - delete items; + delete [] items; } items = born; diff --git a/cde/programs/dtinfo/dtinfogen/infolib/etc/StyleTask.C b/cde/programs/dtinfo/dtinfogen/infolib/etc/StyleTask.C index 0089b755..35ea6984 100644 --- a/cde/programs/dtinfo/dtinfogen/infolib/etc/StyleTask.C +++ b/cde/programs/dtinfo/dtinfogen/infolib/etc/StyleTask.C @@ -146,7 +146,7 @@ write_array(FlexBuffer *buffer, const char *tokens, int quotes) if (quotes) buffer->put( '\"' ); } } - delete str; + free(str); } /*@# else out of memory... */ buffer->put(']'); diff --git a/cde/programs/dtinfo/dtinfogen/infolib/etc/TOCTask.C b/cde/programs/dtinfo/dtinfogen/infolib/etc/TOCTask.C index 927e86ef..557dd567 100644 --- a/cde/programs/dtinfo/dtinfogen/infolib/etc/TOCTask.C +++ b/cde/programs/dtinfo/dtinfogen/infolib/etc/TOCTask.C @@ -178,7 +178,7 @@ int TOCTask::write_tree(DBTable *tbl) INTEGER_CODE, qty, NULL); - delete children; + delete [] children; return qty; } diff --git a/cde/programs/dtinfo/dtinfogen/infolib/etc/Task.C b/cde/programs/dtinfo/dtinfogen/infolib/etc/Task.C index ba072893..7c8ec313 100644 --- a/cde/programs/dtinfo/dtinfogen/infolib/etc/Task.C +++ b/cde/programs/dtinfo/dtinfogen/infolib/etc/Task.C @@ -48,7 +48,7 @@ ComplexTask::~ComplexTask() delete subtasks[i]; } - if ( subtasks ) delete subtasks; + if ( subtasks ) delete [] subtasks; } void ComplexTask::removeAllSubTasks() @@ -57,7 +57,7 @@ void ComplexTask::removeAllSubTasks() delete subtasks[i]; } - if ( subtasks ) { delete subtasks; subtasks = 0; } + if ( subtasks ) { delete [] subtasks; subtasks = NULL; } used = alloc = 0; } @@ -98,7 +98,7 @@ ComplexTask::grow(int needed) if(used){ memcpy(born, subtasks, sizeof(Task*) * used); - delete subtasks; subtasks = 0; + delete [] subtasks; subtasks = NULL; } subtasks = born; -- 2.25.1