Index: lib/libcam/camlib.c =================================================================== --- lib/libcam/camlib.c +++ lib/libcam/camlib.c @@ -94,6 +94,7 @@ cam_freeccb(union ccb *ccb) { free(ccb); + ccb = NULL; } /* @@ -308,6 +309,7 @@ snprintf(cam_errbuf, CAM_ERRBUF_SIZE, "%s: couldn't malloc pattern buffer", func_name); free(ccb.cdm.matches); + ccb.cdm.matches = NULL; close(fd); return(NULL); } @@ -371,7 +373,9 @@ periph_result = &ccb.cdm.matches[0].result.periph_result; pass_unit = periph_result->unit_number; free(ccb.cdm.matches); + ccb.cdm.matches = NULL; free(ccb.cdm.patterns); + ccb.cdm.patterns = NULL; close(fd); sprintf(dev_path, "/dev/pass%d", pass_unit); return(cam_real_open_device(dev_path, flags, device, NULL, @@ -388,7 +392,9 @@ btl_bailout: free(ccb.cdm.matches); + ccb.cdm.matches = NULL; free(ccb.cdm.patterns); + ccb.cdm.patterns = NULL; close(fd); return(NULL); } @@ -653,8 +659,10 @@ if (fd >= 0) close(fd); - if (malloced_device) + if (malloced_device) { free(device); + device = NULL; + } return(NULL); } @@ -668,6 +676,7 @@ cam_close_spec_device(dev); free(dev); + dev = NULL; } void