From: Ian Abbott Date: Wed, 18 Feb 2009 15:35:09 +0000 (+0000) Subject: comedi_get_default_calibration_path(): Check result of asprintf() for error. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=12eedd26b387aea886bafc2e9722c593677cff54;p=comedilib.git comedi_get_default_calibration_path(): Check result of asprintf() for error. --- diff --git a/lib/calib.c b/lib/calib.c index 9415570..0677c63 100644 --- a/lib/calib.c +++ b/lib/calib.c @@ -185,6 +185,7 @@ char* _comedi_get_default_calibration_path( comedi_t *dev ) const char *temp; char *board_name; const char *driver_name; + int err; if(!valid_dev(dev)) return NULL; if( fstat( comedi_fileno( dev ), &file_stats ) < 0 ) @@ -206,10 +207,14 @@ char* _comedi_get_default_calibration_path( comedi_t *dev ) board_name = strdup( temp ); fixup_board_name( board_name ); - asprintf( &file_path, LOCALSTATEDIR "/lib/comedi/calibrations/%s_%s_comedi%li", + err = asprintf( &file_path, LOCALSTATEDIR "/lib/comedi/calibrations/%s_%s_comedi%li", driver_name, board_name, ( unsigned long ) minor( file_stats.st_rdev ) ); free( board_name ); + if( err < 0 ) + { + return NULL; + } return file_path; }