Changeset View
Changeset View
Standalone View
Standalone View
kcms/hardware/joystick/joydevice.cpp
Show First 20 Lines • Show All 174 Lines • ▼ Show 20 Line(s) | 173 | { | |||
---|---|---|---|---|---|
175 | return JoyDevice::ERR_GET_AXES; | 175 | return JoyDevice::ERR_GET_AXES; | ||
176 | } | 176 | } | ||
177 | 177 | | |||
178 | struct js_corr *oldCorr = new struct js_corr[ax]; | 178 | struct js_corr *oldCorr = new struct js_corr[ax]; | ||
179 | 179 | | |||
180 | if ( ::ioctl(fd, JSIOCGCORR, oldCorr) == -1 ) | 180 | if ( ::ioctl(fd, JSIOCGCORR, oldCorr) == -1 ) | ||
181 | { | 181 | { | ||
182 | ::close(fd); | 182 | ::close(fd); | ||
183 | delete [] oldCorr; | 183 | delete [] oldCorr; oldCorr = NULL; | ||
184 | return JoyDevice::ERR_GET_CORR; | 184 | return JoyDevice::ERR_GET_CORR; | ||
185 | } | 185 | } | ||
186 | 186 | | |||
187 | if (bt < 0) { | 187 | if (bt < 0) { | ||
188 | delete [] oldCorr; oldCorr = NULL; | ||||
188 | return JoyDevice::ERR_GET_BUTTONS; | 189 | return JoyDevice::ERR_GET_BUTTONS; | ||
189 | } | 190 | } | ||
190 | 191 | | |||
191 | descr = name; | 192 | descr = name; | ||
192 | joyFd = fd; | 193 | joyFd = fd; | ||
193 | axes = ax; | 194 | axes = ax; | ||
194 | buttons = bt; | 195 | buttons = bt; | ||
195 | origCorr = oldCorr; | 196 | origCorr = oldCorr; | ||
197 | delete [] oldCorr; oldCorr = NULL; | ||||
davidedmundson: When you do this origCorr is now a dangling pointer to deleted contents. | |||||
196 | corr = new struct js_corr[axes]; | 198 | corr = new struct js_corr[axes]; | ||
197 | 199 | | |||
198 | amin = new int[axes]; | 200 | amin = new int[axes]; | ||
199 | amax = new int[axes]; | 201 | amax = new int[axes]; | ||
200 | 202 | | |||
201 | int i; | 203 | int i; | ||
202 | 204 | | |||
203 | for (i = 0; i < axes; i++) | 205 | for (i = 0; i < axes; i++) | ||
▲ Show 20 Lines • Show All 204 Lines • Show Last 20 Lines |
When you do this origCorr is now a dangling pointer to deleted contents.