* LICENSE NOTICES
*
* This file is part of "streamable kanji code filter and converter",
- * which is distributed under the terms of GNU Lesser General Public
+ * which is distributed under the terms of GNU Lesser General Public
* License (version 2) as published by the Free Software Foundation.
*
* This software is distributed in the hope that it will be useful,
unsigned char *tmp;
newlen = device->length + device->allocsz;
+ if (newlen <= 0) {
+ /* overflow */
+ return -1;
+ }
tmp = (unsigned char *)mbfl_realloc((void *)device->buffer, newlen*sizeof(unsigned char));
if (tmp == NULL) {
return -1;
unsigned char *tmp;
newlen = device->length + device->allocsz;
+ if (newlen <= 0) {
+ /* overflow */
+ return -1;
+ }
tmp = (unsigned char *)mbfl_realloc((void *)device->buffer, newlen*sizeof(unsigned char));
if (tmp == NULL) {
return -1;
unsigned char *tmp;
newlen = device->length + device->allocsz;
+ if (newlen <= 0) {
+ /* overflow */
+ return -1;
+ }
tmp = (unsigned char *)mbfl_realloc((void *)device->buffer, newlen*sizeof(unsigned char));
if (tmp == NULL) {
return -1;
if ((device->pos + len) >= device->length) {
/* reallocate buffer */
int newlen = device->length + (len + MBFL_MEMORY_DEVICE_ALLOC_SIZE)*sizeof(unsigned char);
+ if (newlen <= 0) {
+ /* overflow */
+ return -1;
+ }
unsigned char *tmp = (unsigned char *)mbfl_realloc((void *)device->buffer, newlen*sizeof(unsigned char));
if (tmp == NULL) {
return -1;
if ((device->pos + len) >= device->length) {
/* reallocate buffer */
int newlen = device->length + len + MBFL_MEMORY_DEVICE_ALLOC_SIZE;
+ if (newlen <= 0) {
+ /* overflow */
+ return -1;
+ }
unsigned char *tmp = (unsigned char *)mbfl_realloc((void *)device->buffer, newlen*sizeof(unsigned char));
if (tmp == NULL) {
return -1;
if ((dest->pos + src->pos) >= dest->length) {
/* reallocate buffer */
int newlen = dest->length + src->pos + MBFL_MEMORY_DEVICE_ALLOC_SIZE;
+ if (newlen <= 0) {
+ /* overflow */
+ return -1;
+ }
unsigned char *tmp = (unsigned char *)mbfl_realloc((void *)dest->buffer, newlen*sizeof(unsigned char));
if (tmp == NULL) {
return -1;
unsigned int *tmp;
newlen = device->length + device->allocsz;
+ if (newlen <= 0) {
+ /* overflow */
+ return -1;
+ }
tmp = (unsigned int *)mbfl_realloc((void *)device->buffer, newlen*sizeof(int));
if (tmp == NULL) {
return -1;