static size_t cb_read(void *buf, size_t size, size_t nmemb, void *datasource)
{
struct ogg_datasource *ods = datasource;
- size_t copy = PARA_MIN(ods->numbytes - ods->fpos, size * nmemb),
- ret = copy / size;
+ size_t copy, ret;
+
+ if (!size)
+ return 0;
+
+ assert(ods->numbytes >= ods->fpos);
+ ret = ods->numbytes - ods->fpos;
+ copy = PARA_MIN(ret, size * nmemb);
+ ret = copy / size;
if (!ret)
return 0;
memcpy(buf, ods->map + ods->fpos, copy);
struct afh_info *afhi)
{
int ret;
- size_t len = PARA_MIN(numbytes, CHUNK_SIZE);
+ size_t len = PARA_MIN(numbytes, (size_t)CHUNK_SIZE);
int serial;
char *buf;