Converts a series of consecutive null terminated strings into a list Note that a read overflow can result if the input is not properly terminated with an extra NULL. Should probably also add a counted version, as win32api uses for REG_MULTI_SZ
| 364 | // Note that a read overflow can result if the input is not properly terminated with an extra NULL. |
| 365 | // Should probably also add a counted version, as win32api uses for REG_MULTI_SZ |
| 366 | PyObject *PyWinObject_FromMultipleString(WCHAR *multistring) |
| 367 | { |
| 368 | PyObject *obelement, *ret=NULL; |
| 369 | size_t elementlen; |
| 370 | if (multistring==NULL){ |
| 371 | Py_INCREF(Py_None); |
| 372 | return Py_None; |
| 373 | } |
| 374 | ret=PyList_New(0); |
| 375 | if (ret==NULL) |
| 376 | return NULL; |
| 377 | elementlen=wcslen(multistring); |
| 378 | while (elementlen){ |
| 379 | obelement=PyWinObject_FromWCHAR(multistring, elementlen); |
| 380 | if ((obelement==NULL)||(PyList_Append(ret,obelement)==-1)){ |
| 381 | Py_XDECREF(obelement); |
| 382 | Py_DECREF(ret); |
| 383 | return NULL; |
| 384 | } |
| 385 | Py_DECREF(obelement); |
| 386 | multistring+=elementlen+1; |
| 387 | elementlen=wcslen(multistring); |
| 388 | } |
| 389 | return ret; |
| 390 | } |
| 391 | |
| 392 | PyObject *PyWinObject_FromMultipleString(char *multistring) |
| 393 | { |
no outgoing calls
no test coverage detected