View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000995 | Far Manager | Build System | public | 2009-08-05 10:00 | 2009-08-07 15:05 |
Reporter | EvgenyZhirnov | Assigned To | alexy | ||
Priority | normal | Severity | major | Reproducibility | N/A |
Status | closed | Resolution | fixed | ||
Fixed in Version | 2.0 | ||||
Summary | 0000995: Исправление операторов копирования | ||||
Description | В классы ChDiskPluginItem, TArray, TVar, FileFilterParams, FileListItem, MenuItemEx, HistoryRecord, FAR_FIND_DATA_EX, UniSet, TreeItem добавлена проверка в оператор копирование на самого себя:if (this == &rhs) return *this;Для исключения потенциальных ошибок при работе с памятью. | ||||
Tags | No tags attached. | ||||
Build | 1071 | ||||
|
copyOperator.diff (8,245 bytes)
Index: panel.cpp =================================================================== --- panel.cpp (revision 3335) +++ panel.cpp (working copy) @@ -123,8 +123,11 @@ const ChDiskPluginItem& ChDiskPluginItem::operator=(const ChDiskPluginItem &rhs) { - Item=rhs.Item; - HotKey=rhs.HotKey; + if(this!=&rhs) + { + Item=rhs.Item; + HotKey=rhs.HotKey; + } return *this; } Index: array.hpp =================================================================== --- array.hpp (revision 3335) +++ array.hpp (working copy) @@ -244,6 +244,9 @@ template <class Object> TArray<Object>& TArray<Object>::operator=(const TArray<Object> &rhs) { + if(this == &rhs) + return *this; + setDelta(rhs.Delta); if(setSize(rhs.Count)) { Index: tvar.cpp =================================================================== --- tvar.cpp (revision 3335) +++ tvar.cpp (working copy) @@ -77,6 +77,9 @@ vType(v.vType), inum(v.inum) { + if ( this == &v ) + return; + if ( v.str ) { str = new wchar_t[StrLength(v.str)+1]; @@ -89,16 +92,19 @@ TVar& TVar::operator=(const TVar& v) { - vType = v.vType; - inum = v.inum; - if ( str ) - delete [] str; - str = NULL; - if ( v.str ) + if ( this != &v ) { - str = new wchar_t[StrLength(v.str)+1]; - if ( str ) - wcscpy(str, v.str); + vType = v.vType; + inum = v.inum; + if ( str ) + delete [] str; + str = NULL; + if ( v.str ) + { + str = new wchar_t[StrLength(v.str)+1]; + if ( str ) + wcscpy(str, v.str); + } } return *this; } Index: filefilterparams.cpp =================================================================== --- filefilterparams.cpp (revision 3335) +++ filefilterparams.cpp (working copy) @@ -65,17 +65,20 @@ const FileFilterParams &FileFilterParams::operator=(const FileFilterParams &FF) { - SetTitle(FF.GetTitle()); - const wchar_t *Mask; - FF.GetMask(&Mask); - SetMask(FF.GetMask(NULL),Mask); - memcpy(&FSize,&FF.FSize,sizeof(FSize)); - memcpy(&FDate,&FF.FDate,sizeof(FDate)); - memcpy(&FAttr,&FF.FAttr,sizeof(FAttr)); - FF.GetColors(&FHighlight.Colors); - FHighlight.SortGroup=FF.GetSortGroup(); - FHighlight.bContinueProcessing=FF.GetContinueProcessing(); - memcpy(FFlags,FF.FFlags,sizeof(FFlags)); + if (this != &FF) + { + SetTitle(FF.GetTitle()); + const wchar_t *Mask; + FF.GetMask(&Mask); + SetMask(FF.GetMask(NULL),Mask); + memcpy(&FSize,&FF.FSize,sizeof(FSize)); + memcpy(&FDate,&FF.FDate,sizeof(FDate)); + memcpy(&FAttr,&FF.FAttr,sizeof(FAttr)); + FF.GetColors(&FHighlight.Colors); + FHighlight.SortGroup=FF.GetSortGroup(); + FHighlight.bContinueProcessing=FF.GetContinueProcessing(); + memcpy(FFlags,FF.FFlags,sizeof(FFlags)); + } return *this; } Index: filelist.hpp =================================================================== --- filelist.hpp (revision 3335) +++ filelist.hpp (working copy) @@ -120,6 +120,9 @@ FileListItem& operator=(const FileListItem &fliCopy) { + if (this == &fliCopy) + return *this; + Selected = fliCopy.Selected; PrevSelected = fliCopy.PrevSelected; ShowFolderSize = fliCopy.ShowFolderSize; Index: vmenu.hpp =================================================================== --- vmenu.hpp (revision 3335) +++ vmenu.hpp (working copy) @@ -143,16 +143,19 @@ //UserData �� ���������. const MenuItemEx& operator=(const MenuItemEx &srcMenu) { - Flags = srcMenu.Flags; - strName = srcMenu.strName; - AccelKey = srcMenu.AccelKey; - UserDataSize = 0; - UserData = NULL; - AmpPos = srcMenu.AmpPos; - Len[0] = srcMenu.Len[0]; - Len[1] = srcMenu.Len[1]; - Idx2 = srcMenu.Idx2; - ShowPos = srcMenu.ShowPos; + if (this != &srcMenu) + { + Flags = srcMenu.Flags; + strName = srcMenu.strName; + AccelKey = srcMenu.AccelKey; + UserDataSize = 0; + UserData = NULL; + AmpPos = srcMenu.AmpPos; + Len[0] = srcMenu.Len[0]; + Len[1] = srcMenu.Len[1]; + Idx2 = srcMenu.Idx2; + ShowPos = srcMenu.ShowPos; + } return *this; } }; Index: history.hpp =================================================================== --- history.hpp (revision 3335) +++ history.hpp (working copy) @@ -59,11 +59,14 @@ const HistoryRecord& operator=(const HistoryRecord &rhs) { - strName = rhs.strName; - Type = rhs.Type; - Lock = rhs.Lock; - Timestamp.dwLowDateTime = rhs.Timestamp.dwLowDateTime; - Timestamp.dwHighDateTime = rhs.Timestamp.dwHighDateTime; + if (this != &rhs) + { + strName = rhs.strName; + Type = rhs.Type; + Lock = rhs.Lock; + Timestamp.dwLowDateTime = rhs.Timestamp.dwLowDateTime; + Timestamp.dwHighDateTime = rhs.Timestamp.dwHighDateTime; + } return *this; } }; Index: farwinapi.hpp =================================================================== --- farwinapi.hpp (revision 3335) +++ farwinapi.hpp (working copy) @@ -72,14 +72,17 @@ FAR_FIND_DATA_EX& operator=(const FAR_FIND_DATA_EX &ffdexCopy) { - dwFileAttributes=ffdexCopy.dwFileAttributes; - memcpy(&ftCreationTime,&ffdexCopy.ftCreationTime,sizeof(ftCreationTime)); - memcpy(&ftLastAccessTime,&ffdexCopy.ftLastAccessTime,sizeof(ftLastAccessTime)); - memcpy(&ftLastWriteTime,&ffdexCopy.ftLastWriteTime,sizeof(ftLastWriteTime)); - nFileSize=ffdexCopy.nFileSize; - nPackSize=ffdexCopy.nPackSize; - strFileName=ffdexCopy.strFileName; - strAlternateFileName=ffdexCopy.strAlternateFileName; + if (this != &ffdexCopy) + { + dwFileAttributes=ffdexCopy.dwFileAttributes; + memcpy(&ftCreationTime,&ffdexCopy.ftCreationTime,sizeof(ftCreationTime)); + memcpy(&ftLastAccessTime,&ffdexCopy.ftLastAccessTime,sizeof(ftLastAccessTime)); + memcpy(&ftLastWriteTime,&ffdexCopy.ftLastWriteTime,sizeof(ftLastWriteTime)); + nFileSize=ffdexCopy.nFileSize; + nPackSize=ffdexCopy.nPackSize; + strFileName=ffdexCopy.strFileName; + strAlternateFileName=ffdexCopy.strAlternateFileName; + } return *this; } }; Index: RegExp.cpp =================================================================== --- RegExp.cpp (revision 3335) +++ RegExp.cpp (working copy) @@ -220,38 +220,44 @@ } UniSet(const UniSet& src) { - for(int i=0;i<256;i++) + if(this != &src) { - if(src.high[i]) - { - high[i]=new unsigned char[32]; - memcpy(high[i],src.high[i],32); - }else - { - high[i]=NULL; - } + for(int i=0;i<256;i++) + { + if(src.high[i]) + { + high[i]=new unsigned char[32]; + memcpy(high[i],src.high[i],32); + }else + { + high[i]=NULL; + } + } + types=src.types; + nottypes=src.nottypes; + negative=src.negative; } - types=src.types; - nottypes=src.nottypes; - negative=src.negative; } UniSet& operator=(const UniSet& src) { - for(int i=0;i<256;i++) + if(this != &src) { - if(src.high[i]) - { - if(!high[i])high[i]=new unsigned char[32]; - memcpy(high[i],src.high[i],32); - }else - { - if(high[i])delete [] high[i]; - high[i]=NULL; - } + for(int i=0;i<256;i++) + { + if(src.high[i]) + { + if(!high[i])high[i]=new unsigned char[32]; + memcpy(high[i],src.high[i],32); + }else + { + if(high[i])delete [] high[i]; + high[i]=NULL; + } + } + types=src.types; + nottypes=src.nottypes; + negative=src.negative; } - types=src.types; - nottypes=src.nottypes; - negative=src.negative; return (*this); } Index: treelist.hpp =================================================================== --- treelist.hpp (revision 3335) +++ treelist.hpp (working copy) @@ -68,9 +68,12 @@ TreeItem& operator=(const TreeItem &tiCopy) { - strName=tiCopy.strName; - memcpy(Last,tiCopy.Last,sizeof(Last)); - Depth=tiCopy.Depth; + if (this != &tiCopy) + { + strName=tiCopy.strName; + memcpy(Last,tiCopy.Last,sizeof(Last)); + Depth=tiCopy.Depth; + } return *this; } }; |
|
А зачем в конструкторе UniSet(const UniSet& src) ? :) |
|
Просто меня занесло. :) Перезалить патч или исправишь сам? |
|
сам поправлю. |
|
1071 |
|
Это баг кто должен отработать и затем закрыть? Насколько я понимаю, у меня таких прав нет. На попытку отработать пишет Access Denied. |
Date Modified | Username | Field | Change |
---|---|---|---|
2009-08-05 10:00 | EvgenyZhirnov | New Issue | |
2009-08-05 10:00 | EvgenyZhirnov | File Added: copyOperator.diff | |
2009-08-05 10:06 | alexy | Note Added: 0003868 | |
2009-08-05 10:06 | alexy | Status | new => assigned |
2009-08-05 10:06 | alexy | Assigned To | => alexy |
2009-08-05 10:08 | EvgenyZhirnov | Note Added: 0003869 | |
2009-08-05 10:12 | alexy | Note Added: 0003870 | |
2009-08-05 12:59 | alexy | Note Added: 0003871 | |
2009-08-05 12:59 | alexy | Status | assigned => feedback |
2009-08-07 09:11 | EvgenyZhirnov | Note Added: 0003881 | |
2009-08-07 15:05 | alexy | Build | => 1071 |
2009-08-07 15:05 | alexy | Status | feedback => closed |
2009-08-07 15:05 | alexy | Resolution | open => fixed |
2009-08-07 15:05 | alexy | Fixed in Version | => 2.0 |