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->access_mode = _AM_CTRL_SCSI;
_data->gen.b_cdtext_error = false;
_data->gen.init = false;
_data->gen.fd = -1;
_data->gen.toc_init = false;
_data->gen.fd = -1;
_data->gen.b_cdtext_error = false;
if (NULL == psz_orig_source) {
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);
free(psz_source);
} 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->driver_id = DRIVER_AIX;
if (ret == NULL) return NULL;
ret->driver_id = DRIVER_AIX;
if (init_aix(_data))
return ret;
else {
cdio_generic_free (_data);
free(ret);
return NULL;
}

View File

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

View File

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

View File

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

View File

@@ -86,6 +86,6 @@ EXTRA_DIST = cd-drive.help2man cd-info.help2man cd-read.help2man \
if MAINTAINER_MODE
$(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
MAINTAINERCLEANFILES = $(man_MANS) *.rej *.orig