Ticket #2134: gdal-1.5.0-bug-cpl_list.patch
| File gdal-1.5.0-bug-cpl_list.patch, 1.9 kB (added by dgrichard, 4 months ago) |
|---|
-
gdal-1.5.0/port/cpl_list.cpp
old new 111 111 psNew->pData = pData; 112 112 113 113 psCurrent = psList; 114 for ( i = 0; i < nPosition - 1; i++ ) 115 psCurrent = psCurrent->psNext; 116 psNew->psNext = psCurrent->psNext; 117 psCurrent->psNext = psNew; 114 if( nPosition > 0) 115 { 116 for ( i = 0; i < nPosition - 1; i++ ) 117 psCurrent = psCurrent->psNext; 118 psNew->psNext = psCurrent->psNext; 119 psCurrent->psNext = psNew; 120 } 121 else 122 { 123 if ( psList ) 124 { 125 psNew->pData= psList->pData; 126 psNew->psNext= psList->psNext; 127 psList->pData= pData; 128 psList->psNext= psNew; 129 } 130 else 131 { 132 psList= psNew; 133 psNew->psNext= NULL; 134 } 135 } 118 136 } 119 137 120 138 return psList; … … 205 223 /************************************************************************/ 206 224 207 225 /** 208 * Re mone the element from the specified position (zero based) in a list. Data226 * Revone the element from the specified position (zero based) in a list. Data 209 227 * object contained in removed element must be freed by the caller first. 210 228 * 211 229 * @param psList pointer to list head. … … 225 243 return psList; /* Nothing to do!*/ 226 244 227 245 psCurrent = psList; 228 for ( i = 0; i < nPosition - 1; i++ ) 229 psCurrent = psCurrent->psNext; 246 if( nPosition > 0 ) 247 for ( i = 0; i < nPosition - 1; i++ ) 248 psCurrent = psCurrent->psNext; 230 249 psRemoved = psCurrent->psNext; 231 250 psCurrent->psNext = psRemoved->psNext; 232 251 CPLFree( psRemoved );
