diff options
Diffstat (limited to 'linden/indra/lscript/lscript_library.h')
-rw-r--r-- | linden/indra/lscript/lscript_library.h | 89 |
1 files changed, 67 insertions, 22 deletions
diff --git a/linden/indra/lscript/lscript_library.h b/linden/indra/lscript/lscript_library.h index 300cbb6..33fc9d6 100644 --- a/linden/indra/lscript/lscript_library.h +++ b/linden/indra/lscript/lscript_library.h | |||
@@ -182,10 +182,10 @@ public: | |||
182 | size += 4; | 182 | size += 4; |
183 | break; | 183 | break; |
184 | case LST_KEY: | 184 | case LST_KEY: |
185 | size += (S32)strlen(mKey) + 1; | 185 | size += (S32)strlen(mKey) + 1; /*Flawfinder: ignore*/ |
186 | break; | 186 | break; |
187 | case LST_STRING: | 187 | case LST_STRING: |
188 | size += (S32)strlen(mString) + 1; | 188 | size += (S32)strlen(mString) + 1; /*Flawfinder: ignore*/ |
189 | break; | 189 | break; |
190 | case LST_LIST: | 190 | case LST_LIST: |
191 | break; | 191 | break; |
@@ -241,19 +241,29 @@ public: | |||
241 | { | 241 | { |
242 | if (data.mKey) | 242 | if (data.mKey) |
243 | { | 243 | { |
244 | mKey = new char[strlen(data.mKey) + 1]; | 244 | mKey = new char[strlen(data.mKey) + 1]; /* Flawfinder: ignore */ |
245 | strcpy(mKey, data.mKey); | 245 | if (mKey == NULL) |
246 | { | ||
247 | llerrs << "Memory Allocation Failed" << llendl; | ||
248 | return; | ||
249 | } | ||
250 | strcpy(mKey, data.mKey); /* Flawfinder: ignore */ | ||
246 | } | 251 | } |
247 | if (data.mString) | 252 | if (data.mString) |
248 | { | 253 | { |
249 | mString = new char[strlen(data.mString) + 1]; | 254 | mString = new char[strlen(data.mString) + 1]; /* Flawfinder: ignore */ |
250 | strcpy(mString, data.mString); | 255 | if (mString == NULL) |
256 | { | ||
257 | llerrs << "Memory Allocation Failed" << llendl; | ||
258 | return; | ||
259 | } | ||
260 | strcpy(mString, data.mString); /* Flawfinder: ignore */ | ||
251 | } | 261 | } |
252 | } | 262 | } |
253 | 263 | ||
254 | LLScriptLibData(U8 *src, S32 &offset) : mListp(NULL) | 264 | LLScriptLibData(U8 *src, S32 &offset) : mListp(NULL) |
255 | { | 265 | { |
256 | static char temp[TOP_OF_MEMORY]; | 266 | static char temp[TOP_OF_MEMORY]; /* Flawfinder: ignore */ |
257 | mType = (LSCRIPTType)bytestream2integer(src, offset); | 267 | mType = (LSCRIPTType)bytestream2integer(src, offset); |
258 | switch(mType) | 268 | switch(mType) |
259 | { | 269 | { |
@@ -266,15 +276,25 @@ public: | |||
266 | case LST_KEY: | 276 | case LST_KEY: |
267 | { | 277 | { |
268 | bytestream2char(temp, src, offset); | 278 | bytestream2char(temp, src, offset); |
269 | mKey = new char[strlen(temp) + 1]; | 279 | mKey = new char[strlen(temp) + 1]; /* Flawfinder: ignore */ |
270 | strcpy(mKey, temp); | 280 | if (mKey == NULL) |
281 | { | ||
282 | llerrs << "Memory Allocation Failed" << llendl; | ||
283 | return; | ||
284 | } | ||
285 | strcpy(mKey, temp); /* Flawfinder: ignore */ | ||
271 | } | 286 | } |
272 | break; | 287 | break; |
273 | case LST_STRING: | 288 | case LST_STRING: |
274 | { | 289 | { |
275 | bytestream2char(temp, src, offset); | 290 | bytestream2char(temp, src, offset); |
276 | mString = new char[strlen(temp) + 1]; | 291 | mString = new char[strlen(temp) + 1]; /* Flawfinder: ignore */ |
277 | strcpy(mString, temp); | 292 | if (mString == NULL) |
293 | { | ||
294 | llerrs << "Memory Allocation Failed" << llendl; | ||
295 | return; | ||
296 | } | ||
297 | strcpy(mString, temp); /* Flawfinder: ignore */ | ||
278 | } | 298 | } |
279 | break; | 299 | break; |
280 | case LST_LIST: | 300 | case LST_LIST: |
@@ -292,7 +312,7 @@ public: | |||
292 | 312 | ||
293 | void set(U8 *src, S32 &offset) | 313 | void set(U8 *src, S32 &offset) |
294 | { | 314 | { |
295 | static char temp[TOP_OF_MEMORY]; | 315 | static char temp[TOP_OF_MEMORY]; /* Flawfinder: ignore */ |
296 | mType = (LSCRIPTType)bytestream2integer(src, offset); | 316 | mType = (LSCRIPTType)bytestream2integer(src, offset); |
297 | switch(mType) | 317 | switch(mType) |
298 | { | 318 | { |
@@ -305,15 +325,25 @@ public: | |||
305 | case LST_KEY: | 325 | case LST_KEY: |
306 | { | 326 | { |
307 | bytestream2char(temp, src, offset); | 327 | bytestream2char(temp, src, offset); |
308 | mKey = new char[strlen(temp) + 1]; | 328 | mKey = new char[strlen(temp) + 1]; /* Flawfinder: ignore */ |
309 | strcpy(mKey, temp); | 329 | if (mKey == NULL) |
330 | { | ||
331 | llerrs << "Memory Allocation Failed" << llendl; | ||
332 | return; | ||
333 | } | ||
334 | strcpy(mKey, temp); /* Flawfinder: ignore */ | ||
310 | } | 335 | } |
311 | break; | 336 | break; |
312 | case LST_STRING: | 337 | case LST_STRING: |
313 | { | 338 | { |
314 | bytestream2char(temp, src, offset); | 339 | bytestream2char(temp, src, offset); |
315 | mString = new char[strlen(temp) + 1]; | 340 | mString = new char[strlen(temp) + 1]; /* Flawfinder: ignore */ |
316 | strcpy(mString, temp); | 341 | if (mString == NULL) |
342 | { | ||
343 | llerrs << "Memory Allocation Failed" << llendl; | ||
344 | return; | ||
345 | } | ||
346 | strcpy(mString, temp); /* Flawfinder: ignore */ | ||
317 | } | 347 | } |
318 | break; | 348 | break; |
319 | case LST_LIST: | 349 | case LST_LIST: |
@@ -335,8 +365,13 @@ public: | |||
335 | void setFromCSV(char *src) | 365 | void setFromCSV(char *src) |
336 | { | 366 | { |
337 | mType = LST_STRING; | 367 | mType = LST_STRING; |
338 | mString = new char[strlen(src) + 1]; | 368 | mString = new char[strlen(src) + 1]; /* Flawfinder: ignore */ |
339 | strcpy(mString, src); | 369 | if (mString == NULL) |
370 | { | ||
371 | llerrs << "Memory Allocation Failed" << llendl; | ||
372 | return; | ||
373 | } | ||
374 | strcpy(mString, src); /* Flawfinder: ignore */ | ||
340 | } | 375 | } |
341 | 376 | ||
342 | LLScriptLibData(S32 integer) : mType(LST_INTEGER), mInteger(integer), mFP(0.f), mKey(NULL), mString(NULL), mVec(), mQuat(), mListp(NULL) | 377 | LLScriptLibData(S32 integer) : mType(LST_INTEGER), mInteger(integer), mFP(0.f), mKey(NULL), mString(NULL), mVec(), mQuat(), mListp(NULL) |
@@ -362,8 +397,13 @@ public: | |||
362 | } | 397 | } |
363 | else | 398 | else |
364 | { | 399 | { |
365 | mString = new char[strlen(string) + 1]; | 400 | mString = new char[strlen(string) + 1]; /* Flawfinder: ignore */ |
366 | strcpy(mString, string); | 401 | if (mString == NULL) |
402 | { | ||
403 | llerrs << "Memory Allocation Failed" << llendl; | ||
404 | return; | ||
405 | } | ||
406 | strcpy(mString, string); /* Flawfinder: ignore */ | ||
367 | } | 407 | } |
368 | } | 408 | } |
369 | 409 | ||
@@ -376,8 +416,13 @@ public: | |||
376 | } | 416 | } |
377 | else | 417 | else |
378 | { | 418 | { |
379 | mString = new char[strlen(string) + 1]; | 419 | mString = new char[strlen(string) + 1]; /* Flawfinder: ignore */ |
380 | strcpy(mString, string); | 420 | if (mString == NULL) |
421 | { | ||
422 | llerrs << "Memory Allocation Failed" << llendl; | ||
423 | return; | ||
424 | } | ||
425 | strcpy(mString, string); /* Flawfinder: ignore */ | ||
381 | } | 426 | } |
382 | } | 427 | } |
383 | 428 | ||