Skip to content

Commit

Permalink
src/file_io.c : Prevent potential divide-by-zero.
Browse files Browse the repository at this point in the history
Closes: #92
  • Loading branch information
erikd committed Dec 24, 2014
1 parent eea1365 commit 725c7db
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/file_io.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
** Copyright (C) 2002-2013 Erik de Castro Lopo <erikd@mega-nerd.com>
** Copyright (C) 2002-2014 Erik de Castro Lopo <erikd@mega-nerd.com>
** Copyright (C) 2003 Ross Bencina <rbencina@iprimus.com.au>
**
** This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -358,6 +358,9 @@ psf_fwrite (const void *ptr, sf_count_t bytes, sf_count_t items, SF_PRIVATE *psf
{ sf_count_t total = 0 ;
ssize_t count ;

if (bytes == 0 || items == 0)
return 0 ;

if (psf->virtual_io)
return psf->vio.write (ptr, bytes*items, psf->vio_user_data) / bytes ;

Expand Down

0 comments on commit 725c7db

Please sign in to comment.