osx.c: try to eliminate invalid free of an uninitialized structure. untabify various drivers and get this more in-sync with gnu_linux.c driver.

This commit is contained in:
R. Bernstein
2012-04-28 23:38:11 -04:00
parent f8ab393842
commit 37cca69f1d
7 changed files with 454 additions and 431 deletions

View File

@@ -973,14 +973,17 @@ cdio_open_am_aix (const char *psz_orig_source, const char *access_mode)
_data = calloc (1, sizeof (_img_private_t)); _data = calloc (1, sizeof (_img_private_t));
_data->access_mode = _AM_CTRL_SCSI; _data->access_mode = _AM_CTRL_SCSI;
_data->gen.b_cdtext_error = false;
_data->gen.init = false; _data->gen.init = false;
_data->gen.fd = -1;
_data->gen.toc_init = false; _data->gen.toc_init = false;
_data->gen.fd = -1;
_data->gen.b_cdtext_error = false;
if (NULL == psz_orig_source) { if (NULL == psz_orig_source) {
psz_source = cdio_get_default_device_aix(); psz_source = cdio_get_default_device_aix();
if (NULL == psz_source) return NULL; if (NULL == psz_source) {
free(_data);
return NULL;
}
_set_arg_aix(_data, "source", psz_source); _set_arg_aix(_data, "source", psz_source);
free(psz_source); free(psz_source);
} else { } else {
@@ -996,14 +999,15 @@ cdio_open_am_aix (const char *psz_orig_source, const char *access_mode)
} }
ret = cdio_new ( (void *) _data, &_funcs ); ret = cdio_new ( (void *) _data, &_funcs );
ret->driver_id = DRIVER_AIX;
if (ret == NULL) return NULL; if (ret == NULL) return NULL;
ret->driver_id = DRIVER_AIX;
if (init_aix(_data)) if (init_aix(_data))
return ret; return ret;
else { else {
cdio_generic_free (_data); cdio_generic_free (_data);
free(ret);
return NULL; return NULL;
} }

View File

@@ -1023,15 +1023,20 @@ cdio_open_bsdi (const char *psz_orig_source)
}; };
_data = calloc (1, sizeof (_img_private_t)); _data = calloc (1, sizeof (_img_private_t));
_data->access_mode = _AM_IOCTL; _data->access_mode = _AM_IOCTL;
_data->gen.b_cdtext_error = false;
_data->gen.init = false; _data->gen.init = false;
_data->gen.fd = -1;
_data->gen.toc_init = false; _data->gen.toc_init = false;
_data->gen.fd = -1;
_data->gen.b_cdtext_error = false;
if (NULL == psz_orig_source) { if (NULL == psz_orig_source) {
psz_source=cdio_get_default_device_bsdi(); psz_source=cdio_get_default_device_bsdi();
if (NULL == psz_source) return NULL; if (NULL == psz_source) {
free(_data);
return NULL;
}
_set_arg_bsdi(_data, "source", psz_source); _set_arg_bsdi(_data, "source", psz_source);
free(psz_source); free(psz_source);
} else { } else {
@@ -1056,6 +1061,7 @@ cdio_open_bsdi (const char *psz_orig_source)
return ret; return ret;
else { else {
cdio_generic_free (_data); cdio_generic_free (_data);
free(ret);
return NULL; return NULL;
} }

View File

@@ -605,11 +605,12 @@ cdio_open_netbsd(const char *source_name)
_img_private_t *_data; _img_private_t *_data;
_data = calloc(1, sizeof(_img_private_t)); _data = calloc(1, sizeof(_img_private_t));
_data->gen.b_cdtext_error = false;
_data->gen.init = false; _data->gen.init = false;
_data->gen.fd = -1;
_data->toc_valid = false; _data->toc_valid = false;
_data->sessionformat_valid = false; _data->sessionformat_valid = false;
_data->gen.fd = -1;
_data->gen.b_cdtext_error = false;
set_arg_netbsd(_data, "source", set_arg_netbsd(_data, "source",
(source_name ? source_name : DEFAULT_CDIO_DEVICE)); (source_name ? source_name : DEFAULT_CDIO_DEVICE));
@@ -618,18 +619,22 @@ cdio_open_netbsd(const char *source_name)
return (NULL); return (NULL);
ret = cdio_new(&_data->gen, &_funcs); ret = cdio_new(&_data->gen, &_funcs);
if (!ret) if (ret == NULL) return NULL;
return NULL;
ret->driver_id = DRIVER_NETBSD;
if (cdio_generic_init(_data, O_RDONLY)) { if (cdio_generic_init(_data, O_RDONLY)) {
return ret; return ret;
} else { } else {
cdio_generic_free(_data); cdio_generic_free(_data);
free(ret);
return NULL; return NULL;
} }
#else #else
return NULL; return NULL;
#endif /* HAVE_BSDI_CDROM */ #endif /* HAVE_NETBSD_CDROM */
} }
/*! /*!

View File

@@ -1520,6 +1520,7 @@ cdio_open_os2 (const char *psz_orig_source)
return ret; return ret;
else { else {
free_os2 (_data); free_os2 (_data);
free(ret);
return NULL; return NULL;
} }
#else #else

View File

@@ -1944,13 +1944,15 @@ cdio_open_osx (const char *psz_orig_source)
_data->gen.init = false; _data->gen.init = false;
_data->gen.fd = -1; _data->gen.fd = -1;
_data->gen.toc_init = false; _data->gen.toc_init = false;
_data->gen.b_cdtext_error = false;
if (NULL == psz_orig_source) { if (NULL == psz_orig_source) {
psz_source=cdio_get_default_device_osx(); psz_source=cdio_get_default_device_osx();
if (NULL == psz_source) { if (NULL == psz_source) {
cdio_generic_free(_data); free(_data);
return NULL; return NULL;
} }
_set_arg_osx(_data, "source", psz_source); _set_arg_osx(_data, "source", psz_source);
free(psz_source); free(psz_source);
} else { } else {
@@ -1961,21 +1963,21 @@ cdio_open_osx (const char *psz_orig_source)
#if 0 #if 0
cdio_info ("source %s is a not a device", psz_orig_source); cdio_info ("source %s is a not a device", psz_orig_source);
#endif #endif
cdio_generic_free(_data); free(_data);
return NULL; return NULL;
} }
} }
ret = cdio_new ((void *)_data, &_funcs); ret = cdio_new ((void *)_data, &_funcs);
if (ret == NULL) { if (ret == NULL) return NULL;
cdio_generic_free(_data);
return NULL;
}
ret->driver_id = DRIVER_OSX; ret->driver_id = DRIVER_OSX;
if (cdio_generic_init(_data, O_RDONLY | O_NONBLOCK) && init_osx(_data)) if (cdio_generic_init(_data, O_RDONLY | O_NONBLOCK) && init_osx(_data))
return ret; return ret;
else { else {
cdio_generic_free (_data); cdio_generic_free (_data);
free(ret);
return NULL; return NULL;
} }

View File

@@ -1420,7 +1420,11 @@ cdio_open_am_solaris (const char *psz_orig_source, const char *access_mode)
if (NULL == psz_orig_source) { if (NULL == psz_orig_source) {
psz_source = cdio_get_default_device_solaris(); psz_source = cdio_get_default_device_solaris();
if (NULL == psz_source) return NULL; if (NULL == psz_source) {
free(_data);
return NULL;
}
_set_arg_solaris(_data, "source", psz_source); _set_arg_solaris(_data, "source", psz_source);
free(psz_source); free(psz_source);
} else { } else {
@@ -1445,6 +1449,7 @@ cdio_open_am_solaris (const char *psz_orig_source, const char *access_mode)
return ret; return ret;
else { else {
cdio_generic_free (_data); cdio_generic_free (_data);
free(ret);
return NULL; return NULL;
} }

View File

@@ -86,6 +86,6 @@ EXTRA_DIST = cd-drive.help2man cd-info.help2man cd-read.help2man \
if MAINTAINER_MODE if MAINTAINER_MODE
$(man_MANS): %.1: %$(EXEEXT) %.help2man $(man_MANS): %.1: %$(EXEEXT) %.help2man
-$(HELP2MAN) --opt-include=$(srcdir)/$(<:.exe=).help2man --no-info ./$< | @SED@ -re 's/[lL][tT]-//' >$@ -$(HELP2MAN) --opt-include=$(srcdir)/$(<:.exe=).help2man --no-info ./$< | @SED@ @SED_EXTENDED_RE_FLAG@ -e 's/[lL][tT]-//' >$@
endif endif
MAINTAINERCLEANFILES = $(man_MANS) *.rej *.orig MAINTAINERCLEANFILES = $(man_MANS) *.rej *.orig