|
From: Keiichiro O. <ur...@us...> - 2014-11-12 02:26:22
|
Update of /cvsroot/hts-engine/hts_engine_API/src/lib In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv29127/lib Modified Files: HTS_misc.c Log Message: add null check for calloc func Index: HTS_misc.c =================================================================== RCS file: /cvsroot/hts-engine/hts_engine_API/src/lib/HTS_misc.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** HTS_misc.c 24 Dec 2013 03:34:51 -0000 1.19 --- HTS_misc.c 12 Nov 2014 02:26:19 -0000 1.20 *************** *** 251,254 **** --- 251,257 ---- return (size_t) pos.__pos; #endif /* _WIN32 || __CYGWIN__ || __APPLE__ || __ANDROID__ */ + } else if (fp->type == HTS_DATA) { + HTS_Data *d = (HTS_Data *) fp->pointer; + return d->index; } HTS_error(0, "HTS_ftell: Unknown file type.\n"); *************** *** 261,265 **** if (fp == NULL || size == 0 || n == 0) { return 0; ! } else if (fp->type == HTS_FILE) { return fread(buf, size, n, (FILE *) fp->pointer); } else if (fp->type == HTS_DATA) { --- 264,269 ---- if (fp == NULL || size == 0 || n == 0) { return 0; ! } ! if (fp->type == HTS_FILE) { return fread(buf, size, n, (FILE *) fp->pointer); } else if (fp->type == HTS_DATA) { *************** *** 515,522 **** { size_t n = num * size; #ifdef FESTIVAL ! void *mem = (void *) safe_wcalloc(n); #else ! void *mem = (void *) malloc(n); #endif /* FESTIVAL */ --- 519,531 ---- { size_t n = num * size; + void *mem; + + if (n == 0) + return NULL; + #ifdef FESTIVAL ! mem = (void *) safe_wcalloc(n); #else ! mem = (void *) malloc(n); #endif /* FESTIVAL */ *************** *** 555,559 **** { size_t i; ! double **p = (double **) HTS_calloc(x, sizeof(double *)); for (i = 0; i < x; i++) --- 564,573 ---- { size_t i; ! double **p; ! ! if (x == 0 || y == 0) ! return NULL; ! ! p = (double **) HTS_calloc(x, sizeof(double *)); for (i = 0; i < x; i++) |