From 12eedd26b387aea886bafc2e9722c593677cff54 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Wed, 18 Feb 2009 15:35:09 +0000 Subject: [PATCH] comedi_get_default_calibration_path(): Check result of asprintf() for error. --- lib/calib.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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; } -- 2.26.2