summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Lucina <mato@kotelna.sk>2010-06-01 21:49:50 +0200
committerMartin Lucina <mato@kotelna.sk>2010-06-01 21:49:50 +0200
commit74a03dfd7dbb762be5d50eca4df214f8825ad44a (patch)
tree5d2a90854a4e569ef81f1da758c9e483b62828e5
parent99e6179edd9e3552fcdb7f4fce3306cd174f3359 (diff)
parent8a771350795dc4f9aae6a89534f1391d7b63b10c (diff)
Merge branch 'master' of github.com:sustrik/zeromq2
-rw-r--r--AUTHORS2
-rw-r--r--foreign/xmlParser/xmlParser.cpp37
2 files changed, 32 insertions, 7 deletions
diff --git a/AUTHORS b/AUTHORS
index b14a545..79f100a 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -24,6 +24,7 @@ Matus Hamorsky <mhamorsky@gmail.com>
McClain Looney <m@loonsoft.com>
Pavel Gushcha <pavimus@gmail.com>
Pavol Malosek <malosek@fastmq.com>
+Pieter Hintjens <ph@imatix.com>
Steven McCoy <steven.mccoy@miru.hk>
Tamara Kustarova <kustarova.tamara@gmail.com>
Tero Marttila <terom@fixme.fi>
@@ -53,6 +54,5 @@ Michael Santy <Michael.Santy@dynetics.com>
Paulo Henrique Silva <ph.silva@gmail.com>
Peter Busser <busserpeter@gmail.com>
Peter Lemenkov <lemenkov@gmail.com>
-Pieter Hintjens <ph@imatix.com>
Robert Zhang <robert@scout-trading.com>
Toralf Wittner <toralf.wittner@gmail.com>
diff --git a/foreign/xmlParser/xmlParser.cpp b/foreign/xmlParser/xmlParser.cpp
index 70fe1d9..bccfaf7 100644
--- a/foreign/xmlParser/xmlParser.cpp
+++ b/foreign/xmlParser/xmlParser.cpp
@@ -421,7 +421,7 @@ XMLNode XMLNode::openFileHelper(XMLCSTR filename, XMLCSTR tag)
// create message
char message[2000],*s1=(char*)"",*s3=(char*)""; XMLCSTR s2=_CXML("");
if (pResults.error==eXMLErrorFirstTagNotFound) { s1=(char*)"First Tag should be '"; s2=tag; s3=(char*)"'.\n"; }
- sprintf(message,
+ snprintf(message,2000,
#ifdef _XMLWIDECHAR
"XML Parsing error inside file '%S'.\n%S\nAt line %i, column %i.\n%s%S%s"
#else
@@ -608,11 +608,18 @@ XMLError XMLNode::writeToFile(XMLCSTR filename, const char *encoding, char nForm
if (!f) return eXMLErrorCannotOpenWriteFile;
#ifdef _XMLWIDECHAR
unsigned char h[2]={ 0xFF, 0xFE };
- if (!fwrite(h,2,1,f)) return eXMLErrorCannotWriteFile;
+ if (!fwrite(h,2,1,f))
+ {
+ fclose(f);
+ return eXMLErrorCannotWriteFile;
+ }
if ((!isDeclaration())&&((d->lpszName)||(!getChildNode().isDeclaration())))
{
if (!fwrite(L"<?xml version=\"1.0\" encoding=\"utf-16\"?>\n",sizeof(wchar_t)*40,1,f))
+ {
+ fclose(f);
return eXMLErrorCannotWriteFile;
+ }
}
#else
if ((!isDeclaration())&&((d->lpszName)||(!getChildNode().isDeclaration())))
@@ -620,23 +627,41 @@ XMLError XMLNode::writeToFile(XMLCSTR filename, const char *encoding, char nForm
if (characterEncoding==char_encoding_UTF8)
{
// header so that windows recognize the file as UTF-8:
- unsigned char h[3]={0xEF,0xBB,0xBF}; if (!fwrite(h,3,1,f)) return eXMLErrorCannotWriteFile;
+ unsigned char h[3]={0xEF,0xBB,0xBF};
+ if (!fwrite(h,3,1,f))
+ {
+ fclose(f);
+ return eXMLErrorCannotWriteFile;
+ }
encoding="utf-8";
} else if (characterEncoding==char_encoding_ShiftJIS) encoding="SHIFT-JIS";
if (!encoding) encoding="ISO-8859-1";
- if (fprintf(f,"<?xml version=\"1.0\" encoding=\"%s\"?>\n",encoding)<0) return eXMLErrorCannotWriteFile;
+ if (fprintf(f,"<?xml version=\"1.0\" encoding=\"%s\"?>\n",encoding)<0)
+ {
+ fclose(f);
+ return eXMLErrorCannotWriteFile;
+ }
} else
{
if (characterEncoding==char_encoding_UTF8)
{
- unsigned char h[3]={0xEF,0xBB,0xBF}; if (!fwrite(h,3,1,f)) return eXMLErrorCannotWriteFile;
+ unsigned char h[3]={0xEF,0xBB,0xBF};
+ if (!fwrite(h,3,1,f))
+ {
+ fclose(f);
+ return eXMLErrorCannotWriteFile;
+ }
}
}
#endif
int i;
XMLSTR t=createXMLString(nFormat,&i);
- if (!fwrite(t,sizeof(XMLCHAR)*i,1,f)) return eXMLErrorCannotWriteFile;
+ if (!fwrite(t,sizeof(XMLCHAR)*i,1,f))
+ {
+ fclose(f);
+ return eXMLErrorCannotWriteFile;
+ }
if (fclose(f)!=0) return eXMLErrorCannotWriteFile;
free(t);
return eXMLErrorNone;