Пример #1
0
void *
fz_resize_array_no_throw(fz_context *ctx, void *p, unsigned int count, unsigned int size)
{
	if (count == 0 || size == 0)
	{
		fz_free(ctx, p);
		return 0;
	}

	if (count > UINT_MAX / size)
	{
		fprintf(stderr, "error: resize array (%d x %d bytes) failed (integer overflow)\n", count, size);
		return NULL;
	}

	return do_scavenging_realloc(ctx, p, count * size);
}
Пример #2
0
void *
fz_resize_array_no_throw(fz_context *ctx, void *p, size_t count, size_t size)
{
	if (count == 0 || size == 0)
	{
		fz_free(ctx, p);
		return 0;
	}

	if (count > SIZE_MAX / size)
	{
		char buf[100];
		fz_snprintf(buf, sizeof buf, "error: resize array (%zu x %zu bytes) failed (size_t overflow)", count, size);
		fprintf(stderr, "%s\n", buf);
		return NULL;
	}

	return do_scavenging_realloc(ctx, p, count * size);
}
Пример #3
0
void *
fz_resize_array(fz_context *ctx, void *p, unsigned int count, unsigned int size)
{
	void *np;

	if (count == 0 || size == 0)
	{
		fz_free(ctx, p);
		return 0;
	}

	if (count > UINT_MAX / size)
		fz_throw(ctx, "resize array (%d x %d bytes) failed (integer overflow)", count, size);

	np = do_scavenging_realloc(ctx, p, count * size);
	if (!np)
		fz_throw(ctx, "resize array (%d x %d bytes) failed", count, size);
	return np;
}
Пример #4
0
void *
fz_resize_array(fz_context *ctx, void *p, size_t count, size_t size)
{
	void *np;

	if (count == 0 || size == 0)
	{
		fz_free(ctx, p);
		return 0;
	}

	if (count > SIZE_MAX / size)
		fz_throw(ctx, FZ_ERROR_MEMORY, "resize array (%zu x %zu bytes) failed (size_t overflow)", count, size);

	np = do_scavenging_realloc(ctx, p, count * size);
	if (!np)
		fz_throw(ctx, FZ_ERROR_MEMORY, "resize array (%zu x %zu bytes) failed", count, size);
	return np;
}