throw exception instead of failing silently when iconv fails
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3627 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
91a59170e9
commit
efa2113031
1 changed files with 13 additions and 0 deletions
|
@ -26,6 +26,7 @@
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
# include <iconv.h>
|
# include <iconv.h>
|
||||||
|
# include <errno.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
@ -78,11 +79,18 @@ void ReadVarLenArr(BYTE* &seeker, char* &readInto, unsigned int uCodePage) {
|
||||||
{
|
{
|
||||||
delete [] readInto;
|
delete [] readInto;
|
||||||
readInto = 0;
|
readInto = 0;
|
||||||
|
iconv_close(cd);
|
||||||
|
static char err[1024];
|
||||||
|
snprintf(err,1024,"iconv failed (%d)!",errno);
|
||||||
|
throw runtime_error(err);
|
||||||
}
|
}
|
||||||
iconv_close(cd);
|
iconv_close(cd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
readInto = 0;
|
readInto = 0;
|
||||||
|
throw runtime_error("iconv failed! no converter from UCS-2 to current code page");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
seeker += iStrLen * sizeof(WCHAR);
|
seeker += iStrLen * sizeof(WCHAR);
|
||||||
}
|
}
|
||||||
|
@ -130,6 +138,10 @@ void ReadVarLenArr(BYTE* &seeker, char* &readInto, unsigned int uCodePage) {
|
||||||
{ \
|
{ \
|
||||||
*(WCHAR*)seeker = 0; \
|
*(WCHAR*)seeker = 0; \
|
||||||
seeker += sizeof(WCHAR); \
|
seeker += sizeof(WCHAR); \
|
||||||
|
iconv_close(cd); \
|
||||||
|
static char err[1024]; \
|
||||||
|
snprintf(err,1024,"iconv failed (%d)!",errno); \
|
||||||
|
throw runtime_error(err); \
|
||||||
} \
|
} \
|
||||||
seeker = (BYTE *) out; \
|
seeker = (BYTE *) out; \
|
||||||
iconv_close(cd); \
|
iconv_close(cd); \
|
||||||
|
@ -138,6 +150,7 @@ void ReadVarLenArr(BYTE* &seeker, char* &readInto, unsigned int uCodePage) {
|
||||||
{ \
|
{ \
|
||||||
*(WCHAR*)seeker = 0; \
|
*(WCHAR*)seeker = 0; \
|
||||||
seeker += sizeof(WCHAR); \
|
seeker += sizeof(WCHAR); \
|
||||||
|
throw runtime_error("iconv failed! no converter from UCS-2 to current code page"); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue