Changeset 20822 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Jun 23, 2009 12:44:05 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/posix/utf8-posix.cpp
r8245 r20822 45 45 46 46 #ifdef RT_OS_SOLARIS 47 # include <langinfo.h>47 # include <langinfo.h> 48 48 #endif 49 50 #include "internal/alignmentchecks.h" 51 49 52 50 53 /******************************************************************************* … … 73 76 * Allocate buffer 74 77 */ 78 bool fUcs2Term; 75 79 void *pvOutput; 76 80 size_t cbOutput2; … … 81 85 if (!pvOutput) 82 86 return VERR_NO_TMP_MEMORY; 87 fUcs2Term = true; 83 88 } 84 89 else 85 90 { 86 91 pvOutput = *ppvOutput; 87 cbOutput2 = cbOutput - (!strcmp(pszOutputCS, "UCS-2") ? sizeof(RTUTF16) : 1); 92 fUcs2Term = !strcmp(pszOutputCS, "UCS-2"); 93 cbOutput2 = cbOutput - (fUcs2Term ? sizeof(RTUTF16) : 1); 88 94 if (cbOutput2 > cbOutput) 89 95 return VERR_BUFFER_OVERFLOW; … … 105 111 pszOutputCS = nl_langinfo(CODESET); 106 112 #endif 113 IPRT_ALIGNMENT_CHECKS_DISABLE(); /* glibc causes trouble */ 107 114 iconv_t icHandle = iconv_open(pszOutputCS, pszInputCS); 115 IPRT_ALIGNMENT_CHECKS_ENABLE(); 108 116 if (icHandle != (iconv_t)-1) 109 117 { … … 128 136 */ 129 137 iconv_close(icHandle); 130 if (!cbOutput || !strcmp(pszOutputCS, "UCS-2")) 131 *(PRTUTF16)pvOutputLeft = '\0'; 132 else 133 *(char *)pvOutputLeft = '\0'; 138 ((char *)pvOutputLeft)[0] = '\0'; 139 if (fUcs2Term) 140 ((char *)pvOutputLeft)[1] = '\0'; 134 141 *ppvOutput = pvOutput; 135 142 return VINF_SUCCESS; 136 143 } 137 else 138 errno = E2BIG; 144 errno = E2BIG; 139 145 } 140 146 iconv_close(icHandle); … … 150 156 RTMemTmpFree(pvOutput); 151 157 cbOutput2 *= 2; 152 pvOutput = RTMemTmpAlloc(cbOutput2 );158 pvOutput = RTMemTmpAlloc(cbOutput2 + sizeof(RTUTF16)); 153 159 if (!pvOutput) 154 160 return VERR_NO_TMP_MEMORY;
Note:
See TracChangeset
for help on using the changeset viewer.