[Kst] extragear/graphics/kst/kst/datasources/dirfile
George Staikos
staikos at kde.org
Tue Oct 11 19:47:36 CEST 2005
SVN commit 469609 by staikos:
- add an assertion on attempts to allocate a buffer of less than 1 byte
- make the buffer always bigger than 0, but perhaps incorrectly so. Don, I
need some feedback here. What were you trying to do? :)
M +4 -2 getdata.c
--- trunk/extragear/graphics/kst/kst/datasources/dirfile/getdata.c #469608:469609
@@ -7,6 +7,7 @@
* (at your option) any later version. *
* *
***************************************************************************/
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
@@ -929,6 +930,7 @@
/* */
/***************************************************************************/
static void *AllocTmpbuff(char type, int n) {
+ assert(n > 0);
void *buff=NULL;
switch(type) {
case 'n':
@@ -1189,7 +1191,7 @@
spf2 = GetSPF(L->in_fields[i], F, error_code);
if (*error_code != GD_E_OK) return(1);
- tmpbuf = AllocTmpbuff(return_type, *n_read * spf2 / spf1);
+ tmpbuf = AllocTmpbuff(return_type, *n_read * (int)ceil((double)spf2 / spf1));
num_samp = (*n_read * spf2 / spf1) % spf2;
@@ -1258,7 +1260,7 @@
spf2 = GetSPF(M->in_fields[1], F, error_code);
if (*error_code != GD_E_OK) return(1);
- tmpbuf = AllocTmpbuff(return_type, *n_read * spf2 / spf1);
+ tmpbuf = AllocTmpbuff(return_type, *n_read * (int)ceil((double)spf2 / spf1));
n_read2 = DoField(F, M->in_fields[1],
first_frame, first_samp,
More information about the Kst
mailing list