static int i_glinf_d16(i_img *im, int l, int r, int y, i_fcolor *vals);
static int i_plinf_d16(i_img *im, int l, int r, int y, i_fcolor *vals);
static int i_gsamp_d16(i_img *im, int l, int r, int y, i_sample_t *samps,
- int *chans, int chan_count);
+ int const *chans, int chan_count);
static int i_gsampf_d16(i_img *im, int l, int r, int y, i_fsample_t *samps,
- int *chans, int chan_count);
+ int const *chans, int chan_count);
/*
=item IIM_base_16bit_direct
so we check for one otherwise we work by bytes directly
We do assume 8-bit char
+
+ "Compaq C V6.4-009 on Compaq Tru64 UNIX V5.1A (Rev. 1885)" says it
+ supports C99, but doesn't supply stdint.h, which is required for
+ both hosted and freestanding implementations. So guard against it.
*/
-#if __STDC_VERSION__ >= 199901L
+#if __STDC_VERSION__ >= 199901L && !defined(OS_dec_osf)
/* C99 should define something useful */
#include <stdint.h>
#ifdef UINT16_MAX
=cut
*/
i_img *i_img_16_new_low(i_img *im, int x, int y, int ch) {
+ int bytes;
mm_log((1,"i_img_16_new(x %d, y %d, ch %d)\n", x, y, ch));
+
+ if (x < 1 || y < 1) {
+ i_push_error(0, "Image sizes must be positive");
+ return NULL;
+ }
+ if (ch < 1 || ch > MAXCHANNELS) {
+ i_push_errorf(0, "channels must be between 1 and %d", MAXCHANNELS);
+ return NULL;
+ }
+ bytes = x * y * ch * 2;
+ if (bytes / y / ch / 2 != x) {
+ i_push_errorf(0, "integer overflow calculating image allocation");
+ return NULL;
+ }
*im = IIM_base_16bit_direct;
i_tags_new(&im->tags);
im->xsize = x;
im->ysize = y;
im->channels = ch;
- im->bytes = x * y * ch * 2;
+ im->bytes = bytes;
im->ext_data = NULL;
im->idata = mymalloc(im->bytes);
if (im->idata) {
i_img *i_img_16_new(int x, int y, int ch) {
i_img *im;
+
+ i_clear_error();
im = mymalloc(sizeof(i_img));
if (im) {
}
static int i_gsamp_d16(i_img *im, int l, int r, int y, i_sample_t *samps,
- int *chans, int chan_count) {
+ int const *chans, int chan_count) {
int ch, count, i, w;
int off;
}
static int i_gsampf_d16(i_img *im, int l, int r, int y, i_fsample_t *samps,
- int *chans, int chan_count) {
+ int const *chans, int chan_count) {
int ch, count, i, w;
int off;