From 6e751054d8363a316ff85b30272f85792040c207 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Mon, 10 Jan 2011 16:58:10 +0100 Subject: [PATCH] Use size_t type for arguments passed to iconv() On system where sizeof(size_t) != sizeof(uint32_t) iconv() was failing and even segfaulting. Use the correct type and remove the now unneded casts from the iconv() invocations. This makes RCOmage finally work in linux on 64 bit systems as well. Signed-off-by: Antonio Ospite --- src/rcodump.c | 8 ++++---- src/xmlread.c | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/rcodump.c b/src/rcodump.c index 31eb021..bfb620f 100644 --- a/src/rcodump.c +++ b/src/rcodump.c @@ -445,7 +445,7 @@ dump_text_resources (char *labels, rRCOEntry * parent, uint8_t writeHeader, for (i = 0; i < textEntry->numIndexes; i++) { RCOTextIndex *idx = &(textEntry->indexes[i]); uint32_t len = strlen (get_label_from_offset (labels, idx->labelOffset)); - uint32_t dataLen = 0; + size_t dataLen = 0; if (len > MAX_LABEL_LEN) len = MAX_LABEL_LEN; @@ -510,7 +510,7 @@ dump_text_resources (char *labels, rRCOEntry * parent, uint8_t writeHeader, char buf[4096]; char *bufOut = buf; - uint32_t outBufLen = 4096; + size_t outBufLen = 4096; /* { // feed in the BOM (is it really necessary though?) uint32_t * number; char* unicodePtr; if(textEntry->format == @@ -528,8 +528,8 @@ dump_text_resources (char *labels, rRCOEntry * parent, uint8_t writeHeader, uint32_t nullsStripped = 0; while (dataLen) { - iconv (ic, (&bufIn), (size_t *) (&dataLen), &bufOut, - (size_t *) (&outBufLen)); + iconv (ic, (&bufIn), &dataLen, &bufOut, + &outBufLen); if (buf == bufOut) { warning ("iconv failed when converting resource '%s'.", get_label_from_offset (labels, idx->labelOffset)); diff --git a/src/xmlread.c b/src/xmlread.c index 9d72307..180f924 100644 --- a/src/xmlread.c +++ b/src/xmlread.c @@ -1750,8 +1750,8 @@ parse_text_xml (char *fn, rRCOFile * rco, rRCOEntry * entry) } } if (te->indexes[i].length > 2) { - uint32_t contentLen = xmlStrlen (n), outBufLen = - te->indexes[i].length; + size_t contentLen = xmlStrlen (n); + size_t outBufLen = te->indexes[i].length; textBuffer = realloc (textBuffer, @@ -1768,14 +1768,14 @@ parse_text_xml (char *fn, rRCOFile * rco, rRCOEntry * entry) if ((*(uint32_t *) n & 0xFFFFFF) == UTF8_BOM) { char bom[4]; char *bomPtr = bom; - uint32_t bomLen = + size_t bomLen = (fmt == RCO_TEXT_FMT_UTF32 ? 4 : (fmt == RCO_TEXT_FMT_UTF8 ? 3 : 2)); - iconv (ic, (char **) (&n), (size_t *) (&contentLen), - (char **) &bomPtr, (size_t *) (&bomLen)); + iconv (ic, (char **) (&n), &contentLen, + (char **) &bomPtr, &bomLen); } - iconv (ic, (char **) (&n), (size_t *) (&contentLen), &tbPtr, - (size_t *) (&outBufLen)); + iconv (ic, (char **) (&n), &contentLen, &tbPtr, + &outBufLen); if (outBufLen && outBufLen == charWidth) { // *should* // always be // true -- 2.39.5