Skip to content

Commit 725c7db

Browse files
committed
src/file_io.c : Prevent potential divide-by-zero.
Closes: #92
1 parent eea1365 commit 725c7db

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: src/file_io.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** Copyright (C) 2002-2013 Erik de Castro Lopo <erikd@mega-nerd.com>
2+
** Copyright (C) 2002-2014 Erik de Castro Lopo <erikd@mega-nerd.com>
33
** Copyright (C) 2003 Ross Bencina <rbencina@iprimus.com.au>
44
**
55
** This program is free software; you can redistribute it and/or modify
@@ -358,6 +358,9 @@ psf_fwrite (const void *ptr, sf_count_t bytes, sf_count_t items, SF_PRIVATE *psf
358358
{ sf_count_t total = 0 ;
359359
ssize_t count ;
360360

361+
if (bytes == 0 || items == 0)
362+
return 0 ;
363+
361364
if (psf->virtual_io)
362365
return psf->vio.write (ptr, bytes*items, psf->vio_user_data) / bytes ;
363366

0 commit comments

Comments
 (0)