--- format_jpeg.c 2003-11-26 21:35:49.000000000 +0000 +++ format_jpeg.c.new 2003-11-26 21:43:10.000000000 +0000 @@ -39,13 +39,17 @@ static struct ast_frame *jpeg_read_image(int fd, int len) { - struct ast_frame fr; + struct ast_frame fr, *retval; int res; - char buf[65536]; - if (len > sizeof(buf)) { - ast_log(LOG_WARNING, "JPEG image too large to read\n"); + char *buf; + + buf = malloc(len); + + if (buf == NULL) { + ast_log(LOG_WARNING, "Could not allocate %d bytes for JPEG.\n", len); return NULL; } + res = read(fd, buf, len); if (res < len) { ast_log(LOG_WARNING, "Only read %d of %d bytes: %s\n", res, len, strerror(errno)); @@ -56,7 +60,10 @@ fr.data = buf; fr.src = "JPEG Read"; fr.datalen = len; - return ast_frisolate(&fr); + + retval = ast_frisolate(&fr); + free(buf); + return retval; } static int jpeg_identify(int fd)