diff --git a/HTMLparser.c b/HTMLparser.c index fd71aee8..debbe50f 100644 --- a/HTMLparser.c +++ b/HTMLparser.c @@ -2074,8 +2074,8 @@ static const htmlEntityDesc html40EntitiesTable[] = { #define growBuffer(buffer) { \ xmlChar *tmp; \ buffer##_size *= 2; \ - tmp = (xmlChar *) xmlRealloc(buffer, buffer##_size * sizeof(xmlChar)); \ - if (tmp == NULL) { \ + tmp = (xmlChar *) xmlRealloc(buffer, buffer##_size); \ + if (tmp == NULL) { \ htmlErrMemory(ctxt, "growing buffer\n"); \ xmlFree(buffer); \ return(NULL); \ @@ -2744,7 +2744,7 @@ htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) { * allocate a translation buffer. */ buffer_size = HTML_PARSER_BUFFER_SIZE; - buffer = (xmlChar *) xmlMallocAtomic(buffer_size * sizeof(xmlChar)); + buffer = (xmlChar *) xmlMallocAtomic(buffer_size); if (buffer == NULL) { htmlErrMemory(ctxt, "buffer allocation failed\n"); return(NULL); @@ -3380,7 +3380,7 @@ htmlParsePI(htmlParserCtxtPtr ctxt) { ctxt->instate = state; return; } - buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); + buf = (xmlChar *) xmlMallocAtomic(size); if (buf == NULL) { htmlErrMemory(ctxt, NULL); ctxt->instate = state; @@ -3398,7 +3398,7 @@ htmlParsePI(htmlParserCtxtPtr ctxt) { xmlChar *tmp; size *= 2; - tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); + tmp = (xmlChar *) xmlRealloc(buf, size); if (tmp == NULL) { htmlErrMemory(ctxt, NULL); xmlFree(buf); @@ -3480,7 +3480,7 @@ htmlParseComment(htmlParserCtxtPtr ctxt) { ctxt->instate = XML_PARSER_COMMENT; SHRINK; SKIP(4); - buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); + buf = (xmlChar *) xmlMallocAtomic(size); if (buf == NULL) { htmlErrMemory(ctxt, "buffer allocation failed\n"); ctxt->instate = state; @@ -3529,7 +3529,7 @@ htmlParseComment(htmlParserCtxtPtr ctxt) { xmlChar *tmp; size *= 2; - tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); + tmp = (xmlChar *) xmlRealloc(buf, size); if (tmp == NULL) { xmlFree(buf); htmlErrMemory(ctxt, "growing buffer failed\n"); diff --git a/buf.c b/buf.c index 85313b6c..9b2a7d19 100644 --- a/buf.c +++ b/buf.c @@ -135,7 +135,7 @@ xmlBufCreate(void) { ret->size = xmlDefaultBufferSize; UPDATE_COMPAT(ret); ret->alloc = xmlBufferAllocScheme; - ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar)); + ret->content = (xmlChar *) xmlMallocAtomic(ret->size); if (ret->content == NULL) { xmlBufMemoryError(ret, "creating buffer"); xmlFree(ret); @@ -171,7 +171,7 @@ xmlBufCreateSize(size_t size) { ret->size = (size ? size + 1 : 0); /* +1 for ending null */ UPDATE_COMPAT(ret); if (ret->size){ - ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar)); + ret->content = (xmlChar *) xmlMallocAtomic(ret->size); if (ret->content == NULL) { xmlBufMemoryError(ret, "creating buffer"); xmlFree(ret); @@ -538,7 +538,7 @@ xmlBufDump(FILE *file, xmlBufPtr buf) { CHECK_COMPAT(buf) if (file == NULL) file = stdout; - ret = fwrite(buf->content, sizeof(xmlChar), buf->use, file); + ret = fwrite(buf->content, 1, buf->use, file); return(ret); } @@ -865,7 +865,7 @@ xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len) { } } - memmove(&buf->content[buf->use], str, len*sizeof(xmlChar)); + memmove(&buf->content[buf->use], str, len); buf->use += len; buf->content[buf->use] = 0; UPDATE_COMPAT(buf) diff --git a/c14n.c b/c14n.c index 78eb82ae..717e5cec 100644 --- a/c14n.c +++ b/c14n.c @@ -2116,7 +2116,7 @@ xmlC14NDocSave(xmlDocPtr doc, xmlNodeSetPtr nodes, #define growBufferReentrant() { \ buffer_size *= 2; \ buffer = (xmlChar *) \ - xmlRealloc(buffer, buffer_size * sizeof(xmlChar)); \ + xmlRealloc(buffer, buffer_size); \ if (buffer == NULL) { \ xmlC14NErrMemory("growing buffer"); \ return(NULL); \ @@ -2151,7 +2151,7 @@ xmlC11NNormalizeString(const xmlChar * input, * allocate an translation buffer. */ buffer_size = 1000; - buffer = (xmlChar *) xmlMallocAtomic(buffer_size * sizeof(xmlChar)); + buffer = (xmlChar *) xmlMallocAtomic(buffer_size); if (buffer == NULL) { xmlC14NErrMemory("allocating buffer"); return (NULL); diff --git a/catalog.c b/catalog.c index 0fa45d1f..5b0013fc 100644 --- a/catalog.c +++ b/catalog.c @@ -2187,7 +2187,7 @@ xmlParseSGMLCatalogPubid(const xmlChar *cur, xmlChar **id) { } else { stop = ' '; } - buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); + buf = (xmlChar *) xmlMallocAtomic(size); if (buf == NULL) { xmlCatalogErrMemory("allocating public ID"); return(NULL); @@ -2199,7 +2199,7 @@ xmlParseSGMLCatalogPubid(const xmlChar *cur, xmlChar **id) { break; if (len + 1 >= size) { size *= 2; - tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); + tmp = (xmlChar *) xmlRealloc(buf, size); if (tmp == NULL) { xmlCatalogErrMemory("allocating public ID"); xmlFree(buf); diff --git a/entities.c b/entities.c index a25349e7..7876f708 100644 --- a/entities.c +++ b/entities.c @@ -628,7 +628,7 @@ xmlEncodeEntitiesInternal(xmlDocPtr doc, const xmlChar *input, int attr) { * allocate an translation buffer. */ buffer_size = 1000; - buffer = (xmlChar *) xmlMalloc(buffer_size * sizeof(xmlChar)); + buffer = (xmlChar *) xmlMalloc(buffer_size); if (buffer == NULL) { xmlEntitiesErrMemory("xmlEncodeEntities: malloc failed"); return(NULL); @@ -868,7 +868,7 @@ xmlEncodeSpecialChars(const xmlDoc *doc ATTRIBUTE_UNUSED, const xmlChar *input) * allocate an translation buffer. */ buffer_size = 1000; - buffer = (xmlChar *) xmlMalloc(buffer_size * sizeof(xmlChar)); + buffer = (xmlChar *) xmlMalloc(buffer_size); if (buffer == NULL) { xmlEntitiesErrMemory("xmlEncodeSpecialChars: malloc failed"); return(NULL); diff --git a/nanohttp.c b/nanohttp.c index cfd59eea..3b1ecb0b 100644 --- a/nanohttp.c +++ b/nanohttp.c @@ -538,7 +538,7 @@ xmlNanoHTTPRecv(xmlNanoHTTPCtxtPtr ctxt) while (ctxt->state & XML_NANO_HTTP_READ) { if (ctxt->in == NULL) { - ctxt->in = (char *) xmlMallocAtomic(65000 * sizeof(char)); + ctxt->in = (char *) xmlMallocAtomic(65000); if (ctxt->in == NULL) { xmlHTTPErrMemory("allocating input"); ctxt->last = -1; diff --git a/parser.c b/parser.c index 8f6baa11..e701e57f 100644 --- a/parser.c +++ b/parser.c @@ -2987,7 +2987,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) { */ max = len * 2; - buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar)); + buffer = (xmlChar *) xmlMallocAtomic(max); if (buffer == NULL) { xmlErrMemory(ctxt, NULL); return(NULL); @@ -2998,8 +2998,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) { xmlChar *tmp; max *= 2; - tmp = (xmlChar *) xmlRealloc(buffer, - max * sizeof(xmlChar)); + tmp = (xmlChar *) xmlRealloc(buffer, max); if (tmp == NULL) { xmlFree(buffer); xmlErrMemory(ctxt, NULL); @@ -3066,7 +3065,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) { */ max = len * 2; - buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar)); + buffer = (xmlChar *) xmlMallocAtomic(max); if (buffer == NULL) { xmlErrMemory(ctxt, NULL); return(NULL); @@ -3077,8 +3076,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) { xmlChar *tmp; max *= 2; - tmp = (xmlChar *) xmlRealloc(buffer, - max * sizeof(xmlChar)); + tmp = (xmlChar *) xmlRealloc(buffer, max); if (tmp == NULL) { xmlErrMemory(ctxt, NULL); xmlFree(buffer); @@ -3603,7 +3601,7 @@ xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar** str) { xmlChar *buffer; int max = len * 2; - buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar)); + buffer = (xmlChar *) xmlMallocAtomic(max); if (buffer == NULL) { xmlErrMemory(ctxt, NULL); return(NULL); @@ -3620,8 +3618,7 @@ xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar** str) { return(NULL); } max *= 2; - tmp = (xmlChar *) xmlRealloc(buffer, - max * sizeof(xmlChar)); + tmp = (xmlChar *) xmlRealloc(buffer, max); if (tmp == NULL) { xmlErrMemory(ctxt, NULL); xmlFree(buffer); @@ -3701,7 +3698,7 @@ xmlParseNmtoken(xmlParserCtxtPtr ctxt) { xmlChar *buffer; int max = len * 2; - buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar)); + buffer = (xmlChar *) xmlMallocAtomic(max); if (buffer == NULL) { xmlErrMemory(ctxt, NULL); return(NULL); @@ -3726,8 +3723,7 @@ xmlParseNmtoken(xmlParserCtxtPtr ctxt) { return(NULL); } max *= 2; - tmp = (xmlChar *) xmlRealloc(buffer, - max * sizeof(xmlChar)); + tmp = (xmlChar *) xmlRealloc(buffer, max); if (tmp == NULL) { xmlErrMemory(ctxt, NULL); xmlFree(buffer); @@ -3785,7 +3781,7 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) { xmlFatalErr(ctxt, XML_ERR_ENTITY_NOT_STARTED, NULL); return(NULL); } - buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); + buf = (xmlChar *) xmlMallocAtomic(size); if (buf == NULL) { xmlErrMemory(ctxt, NULL); return(NULL); @@ -3817,7 +3813,7 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) { xmlChar *tmp; size *= 2; - tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); + tmp = (xmlChar *) xmlRealloc(buf, size); if (tmp == NULL) { xmlErrMemory(ctxt, NULL); goto error; @@ -4229,7 +4225,7 @@ xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) { return(NULL); } - buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); + buf = (xmlChar *) xmlMallocAtomic(size); if (buf == NULL) { xmlErrMemory(ctxt, NULL); return(NULL); @@ -4248,7 +4244,7 @@ xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) { return(NULL); } size *= 2; - tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); + tmp = (xmlChar *) xmlRealloc(buf, size); if (tmp == NULL) { xmlFree(buf); xmlErrMemory(ctxt, NULL); @@ -4320,7 +4316,7 @@ xmlParsePubidLiteral(xmlParserCtxtPtr ctxt) { xmlFatalErr(ctxt, XML_ERR_LITERAL_NOT_STARTED, NULL); return(NULL); } - buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); + buf = (xmlChar *) xmlMallocAtomic(size); if (buf == NULL) { xmlErrMemory(ctxt, NULL); return(NULL); @@ -4338,7 +4334,7 @@ xmlParsePubidLiteral(xmlParserCtxtPtr ctxt) { return(NULL); } size *= 2; - tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); + tmp = (xmlChar *) xmlRealloc(buf, size); if (tmp == NULL) { xmlErrMemory(ctxt, NULL); xmlFree(buf); @@ -4774,7 +4770,7 @@ xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf, if (buf == NULL) { len = 0; size = XML_PARSER_BUFFER_SIZE; - buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); + buf = (xmlChar *) xmlMallocAtomic(size); if (buf == NULL) { xmlErrMemory(ctxt, NULL); return; @@ -4960,7 +4956,7 @@ get_more: size = nbchar + 1; else size = XML_PARSER_BUFFER_SIZE + nbchar; - buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); + buf = (xmlChar *) xmlMallocAtomic(size); if (buf == NULL) { xmlErrMemory(ctxt, NULL); ctxt->instate = state; @@ -4970,8 +4966,7 @@ get_more: } else if (len + nbchar + 1 >= size) { xmlChar *new_buf; size += len + nbchar + XML_PARSER_BUFFER_SIZE; - new_buf = (xmlChar *) xmlRealloc(buf, - size * sizeof(xmlChar)); + new_buf = (xmlChar *) xmlRealloc(buf, size); if (new_buf == NULL) { xmlFree (buf); xmlErrMemory(ctxt, NULL); @@ -5230,7 +5225,7 @@ xmlParsePI(xmlParserCtxtPtr ctxt) { ctxt->instate = state; return; } - buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); + buf = (xmlChar *) xmlMallocAtomic(size); if (buf == NULL) { xmlErrMemory(ctxt, NULL); ctxt->instate = state; @@ -9866,7 +9861,7 @@ xmlParseCDSect(xmlParserCtxtPtr ctxt) { } NEXTL(sl); cur = CUR_CHAR(l); - buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); + buf = (xmlChar *) xmlMallocAtomic(size); if (buf == NULL) { xmlErrMemory(ctxt, NULL); return; @@ -9883,7 +9878,7 @@ xmlParseCDSect(xmlParserCtxtPtr ctxt) { xmlFree (buf); return; } - tmp = (xmlChar *) xmlRealloc(buf, size * 2 * sizeof(xmlChar)); + tmp = (xmlChar *) xmlRealloc(buf, size * 2); if (tmp == NULL) { xmlFree(buf); xmlErrMemory(ctxt, NULL); @@ -10266,7 +10261,7 @@ xmlParseVersionNum(xmlParserCtxtPtr ctxt) { int size = 10; xmlChar cur; - buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); + buf = (xmlChar *) xmlMallocAtomic(size); if (buf == NULL) { xmlErrMemory(ctxt, NULL); return(NULL); @@ -10291,7 +10286,7 @@ xmlParseVersionNum(xmlParserCtxtPtr ctxt) { xmlChar *tmp; size *= 2; - tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); + tmp = (xmlChar *) xmlRealloc(buf, size); if (tmp == NULL) { xmlFree(buf); xmlErrMemory(ctxt, NULL); @@ -10378,7 +10373,7 @@ xmlParseEncName(xmlParserCtxtPtr ctxt) { cur = CUR; if (((cur >= 'a') && (cur <= 'z')) || ((cur >= 'A') && (cur <= 'Z'))) { - buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); + buf = (xmlChar *) xmlMallocAtomic(size); if (buf == NULL) { xmlErrMemory(ctxt, NULL); return(NULL); @@ -10396,7 +10391,7 @@ xmlParseEncName(xmlParserCtxtPtr ctxt) { xmlChar *tmp; size *= 2; - tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); + tmp = (xmlChar *) xmlRealloc(buf, size); if (tmp == NULL) { xmlErrMemory(ctxt, NULL); xmlFree(buf); diff --git a/relaxng.c b/relaxng.c index 42543742..a72c715e 100644 --- a/relaxng.c +++ b/relaxng.c @@ -8588,7 +8588,7 @@ xmlRelaxNGNormalize(xmlRelaxNGValidCtxtPtr ctxt, const xmlChar * str) tmp++; len = tmp - str; - ret = (xmlChar *) xmlMallocAtomic((len + 1) * sizeof(xmlChar)); + ret = (xmlChar *) xmlMallocAtomic(len + 1); if (ret == NULL) { xmlRngVErrMemory(ctxt, "validating\n"); return (NULL); diff --git a/schematron.c b/schematron.c index 5f71f060..51d7c38f 100644 --- a/schematron.c +++ b/schematron.c @@ -1508,7 +1508,7 @@ xmlSchematronFormatReport(xmlSchematronValidCtxtPtr ctxt, int size; size = snprintf(NULL, 0, "%0g", eval->floatval); - buf = (xmlChar*) malloc(size * sizeof(xmlChar)); + buf = (xmlChar*) malloc(size); /* xmlStrPrintf(buf, size, "%0g", eval->floatval); // doesn't work */ sprintf((char*) buf, "%0g", eval->floatval); ret = xmlStrcat(ret, buf); diff --git a/tree.c b/tree.c index b296d920..36b0a77a 100644 --- a/tree.c +++ b/tree.c @@ -4810,12 +4810,12 @@ xmlGetNodePath(const xmlNode *node) return (NULL); buf_len = 500; - buffer = (xmlChar *) xmlMallocAtomic(buf_len * sizeof(xmlChar)); + buffer = (xmlChar *) xmlMallocAtomic(buf_len); if (buffer == NULL) { xmlTreeErrMemory("getting node path"); return (NULL); } - buf = (xmlChar *) xmlMallocAtomic(buf_len * sizeof(xmlChar)); + buf = (xmlChar *) xmlMallocAtomic(buf_len); if (buf == NULL) { xmlTreeErrMemory("getting node path"); xmlFree(buffer); @@ -7148,7 +7148,7 @@ xmlBufferCreate(void) { ret->use = 0; ret->size = xmlDefaultBufferSize; ret->alloc = xmlBufferAllocScheme; - ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar)); + ret->content = (xmlChar *) xmlMallocAtomic(ret->size); if (ret->content == NULL) { xmlTreeErrMemory("creating buffer"); xmlFree(ret); @@ -7181,7 +7181,7 @@ xmlBufferCreateSize(size_t size) { ret->alloc = xmlBufferAllocScheme; ret->size = (size ? size + 1 : 0); /* +1 for ending null */ if (ret->size){ - ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar)); + ret->content = (xmlChar *) xmlMallocAtomic(ret->size); if (ret->content == NULL) { xmlTreeErrMemory("creating buffer"); xmlFree(ret); @@ -7458,7 +7458,7 @@ xmlBufferDump(FILE *file, xmlBufferPtr buf) { } if (file == NULL) file = stdout; - ret = fwrite(buf->content, sizeof(xmlChar), buf->use, file); + ret = fwrite(buf->content, 1, buf->use, file); return(ret > INT_MAX ? INT_MAX : ret); } @@ -7665,7 +7665,7 @@ xmlBufferAdd(xmlBufferPtr buf, const xmlChar *str, int len) { } } - memmove(&buf->content[buf->use], str, len*sizeof(xmlChar)); + memmove(&buf->content[buf->use], str, len); buf->use += len; buf->content[buf->use] = 0; return 0; diff --git a/uri.c b/uri.c index 95d11fa7..cf23c3f4 100644 --- a/uri.c +++ b/uri.c @@ -1076,7 +1076,7 @@ xmlSaveUri(xmlURIPtr uri) { max = 80; - ret = (xmlChar *) xmlMallocAtomic((max + 1) * sizeof(xmlChar)); + ret = (xmlChar *) xmlMallocAtomic(max + 1); if (ret == NULL) { xmlURIErrMemory("saving URI\n"); return(NULL); diff --git a/xmlIO.c b/xmlIO.c index 578c2171..ab3b15b3 100644 --- a/xmlIO.c +++ b/xmlIO.c @@ -2035,8 +2035,7 @@ xmlIOHTTPCloseWrite( void * context, const char * http_mthd ) { xmlGenericError( xmlGenericErrorContext, "Transmitted content saved in file: %s\n", buffer ); - fwrite( http_content, sizeof( char ), - content_lgth, tst_file ); + fwrite( http_content, 1, content_lgth, tst_file ); fclose( tst_file ); } @@ -2050,7 +2049,7 @@ xmlIOHTTPCloseWrite( void * context, const char * http_mthd ) { while ( (avail = xmlNanoHTTPRead( http_ctxt, buffer, sizeof( buffer ) )) > 0 ) { - fwrite( buffer, sizeof( char ), avail, tst_file ); + fwrite( buffer, 1, avail, tst_file ); } fclose( tst_file ); diff --git a/xmlschemastypes.c b/xmlschemastypes.c index 79825be0..131d4b67 100644 --- a/xmlschemastypes.c +++ b/xmlschemastypes.c @@ -3222,8 +3222,7 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value, if (v == NULL) goto error; base = - (xmlChar *) xmlMallocAtomic((i + pad + 1) * - sizeof(xmlChar)); + (xmlChar *) xmlMallocAtomic(i + pad + 1); if (base == NULL) { xmlSchemaTypeErrMemory(node, "allocating base64 data"); xmlFree(v); diff --git a/xmlstring.c b/xmlstring.c index 2bd7e6a6..639ad0a0 100644 --- a/xmlstring.c +++ b/xmlstring.c @@ -46,12 +46,12 @@ xmlStrndup(const xmlChar *cur, int len) { xmlChar *ret; if ((cur == NULL) || (len < 0)) return(NULL); - ret = (xmlChar *) xmlMallocAtomic(((size_t) len + 1) * sizeof(xmlChar)); + ret = (xmlChar *) xmlMallocAtomic((size_t) len + 1); if (ret == NULL) { xmlErrMemory(NULL, NULL); return(NULL); } - memcpy(ret, cur, len * sizeof(xmlChar)); + memcpy(ret, cur, len); ret[len] = 0; return(ret); } @@ -91,7 +91,7 @@ xmlCharStrndup(const char *cur, int len) { xmlChar *ret; if ((cur == NULL) || (len < 0)) return(NULL); - ret = (xmlChar *) xmlMallocAtomic(((size_t) len + 1) * sizeof(xmlChar)); + ret = (xmlChar *) xmlMallocAtomic((size_t) len + 1); if (ret == NULL) { xmlErrMemory(NULL, NULL); return(NULL); @@ -460,12 +460,12 @@ xmlStrncat(xmlChar *cur, const xmlChar *add, int len) { size = xmlStrlen(cur); if ((size < 0) || (size > INT_MAX - len)) return(NULL); - ret = (xmlChar *) xmlRealloc(cur, ((size_t) size + len + 1) * sizeof(xmlChar)); + ret = (xmlChar *) xmlRealloc(cur, (size_t) size + len + 1); if (ret == NULL) { xmlErrMemory(NULL, NULL); return(cur); } - memcpy(&ret[size], add, len * sizeof(xmlChar)); + memcpy(&ret[size], add, len); ret[size + len] = 0; return(ret); } @@ -500,13 +500,13 @@ xmlStrncatNew(const xmlChar *str1, const xmlChar *str2, int len) { size = xmlStrlen(str1); if ((size < 0) || (size > INT_MAX - len)) return(NULL); - ret = (xmlChar *) xmlMalloc(((size_t) size + len + 1) * sizeof(xmlChar)); + ret = (xmlChar *) xmlMalloc((size_t) size + len + 1); if (ret == NULL) { xmlErrMemory(NULL, NULL); return(xmlStrndup(str1, size)); } - memcpy(ret, str1, size * sizeof(xmlChar)); - memcpy(&ret[size], str2, len * sizeof(xmlChar)); + memcpy(ret, str1, size); + memcpy(&ret[size], str2, len); ret[size + len] = 0; return(ret); } @@ -874,11 +874,11 @@ xmlUTF8Strndup(const xmlChar *utf, int len) { if ((utf == NULL) || (len < 0)) return(NULL); i = xmlUTF8Strsize(utf, len); - ret = (xmlChar *) xmlMallocAtomic(((size_t) i + 1) * sizeof(xmlChar)); + ret = (xmlChar *) xmlMallocAtomic((size_t) i + 1); if (ret == NULL) { return(NULL); } - memcpy(ret, utf, i * sizeof(xmlChar)); + memcpy(ret, utf, i); ret[i] = 0; return(ret); } @@ -1025,7 +1025,7 @@ xmlEscapeFormatString(xmlChar **msg) if ((count > INT_MAX) || (msgLen > INT_MAX - count)) return(NULL); resultLen = msgLen + count + 1; - result = (xmlChar *) xmlMallocAtomic(resultLen * sizeof(xmlChar)); + result = (xmlChar *) xmlMallocAtomic(resultLen); if (result == NULL) { /* Clear *msg to prevent format string vulnerabilities in out-of-memory situations. */ diff --git a/xpath.c b/xpath.c index abc08c98..9ad0f0e1 100644 --- a/xpath.c +++ b/xpath.c @@ -9921,7 +9921,7 @@ xmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt, int qualified) { if (len > XML_MAX_NAME_LENGTH) { XP_ERRORNULL(XPATH_EXPR_ERROR); } - buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar)); + buffer = (xmlChar *) xmlMallocAtomic(max); if (buffer == NULL) { XP_ERRORNULL(XPATH_MEMORY_ERROR); } @@ -9938,8 +9938,7 @@ xmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt, int qualified) { XP_ERRORNULL(XPATH_EXPR_ERROR); } max *= 2; - tmp = (xmlChar *) xmlRealloc(buffer, - max * sizeof(xmlChar)); + tmp = (xmlChar *) xmlRealloc(buffer, max); if (tmp == NULL) { xmlFree(buffer); XP_ERRORNULL(XPATH_MEMORY_ERROR); diff --git a/xpointer.c b/xpointer.c index 63177f5a..d8c18d7a 100644 --- a/xpointer.c +++ b/xpointer.c @@ -969,7 +969,7 @@ xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) { len = xmlStrlen(ctxt->cur); len++; - buffer = (xmlChar *) xmlMallocAtomic(len * sizeof (xmlChar)); + buffer = (xmlChar *) xmlMallocAtomic(len); if (buffer == NULL) { xmlXPtrErrMemory("allocating buffer"); xmlFree(name);