More memory management changes proposed by Joris Dobbelsteen

ZeroFourZero
Thomas Schmitt 15 years ago
parent bcb56b5e9e
commit dcf35bd556
  1. 2
      cdrskin/cdrskin_timestamp.h
  2. 8
      libburn/file.c
  3. 9
      libburn/mmc.c

@ -1 +1 @@
#define Cdrskin_timestamP "2007.08.25.085709"
#define Cdrskin_timestamP "2007.08.25.155931"

@ -93,7 +93,7 @@ struct burn_source *burn_file_source_new(const char *path, const char *subpath)
{
struct burn_source_file *fs;
struct burn_source *src;
int fd1, fd2 = 0;
int fd1 = -1, fd2 = -1;
if (!path)
return NULL;
@ -113,15 +113,13 @@ struct burn_source *burn_file_source_new(const char *path, const char *subpath)
if (fs == NULL) {
failure:;
close(fd1);
if (subpath != NULL)
if (fd2 >= 0)
close(fd2);
return NULL;
}
fs->datafd = fd1;
if (subpath)
fs->subfd = fd2;
fs->subfd = fd2;
/* ts A70125 */
fs->fixed_size = 0;

@ -959,10 +959,7 @@ static int mmc_read_toc_al(struct burn_drive *d, int *alloc_len)
d->status = BURN_DISC_UNSUITABLE;
d->toc_entries = 0;
/* Prefering memory leaks over fandangos */
d->toc_entry = malloc(sizeof(struct burn_toc_entry));
if (d->toc_entry != NULL) /* ts A70825 */
memset(&(d->toc_entry[0]), 0,
sizeof(struct burn_toc_entry));
d->toc_entry = calloc(1, sizeof(struct burn_toc_entry));
return 0;
}
@ -982,11 +979,9 @@ static int mmc_read_toc_al(struct burn_drive *d, int *alloc_len)
ts A61007 : if re-enabled then not via Assert.
a ssert(((dlen - 2) % 11) == 0);
*/
d->toc_entry = malloc(d->toc_entries * sizeof(struct burn_toc_entry));
d->toc_entry = calloc(d->toc_entries, sizeof(struct burn_toc_entry));
if(d->toc_entry == NULL) /* ts A70825 */
return 0;
for (i = 0; i < d->toc_entries; i++)
memset(&(d->toc_entry[i]), 0, sizeof(struct burn_toc_entry));
tdata = c.page->data + 4;
burn_print(12, "TOC:\n");

Loading…
Cancel
Save