Remove some valgrind-caught memory leaks or use of uninitialized regions.

This commit is contained in:
rocky
2005-01-23 05:31:03 +00:00
parent 09c1a1d180
commit 4fabb2857e
10 changed files with 39 additions and 27 deletions

View File

@@ -1,5 +1,5 @@
/*
$Id: scan_devices.c,v 1.15 2005/01/22 03:45:19 rocky Exp $
$Id: scan_devices.c,v 1.16 2005/01/23 05:31:03 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
Copyright (C) 1998 Monty xiphmont@mit.edu
@@ -307,9 +307,12 @@ cdda_identify_cooked(const char *psz_dev, int messagedest,
char *psz_device = test_resolve_symlink(psz_dev, messagedest,
ppsz_messages);
if ( psz_device ) {
cdrom_drive_t *d=NULL;
p_cdio = cdio_open(psz_device, DRIVER_UNKNOWN);
return cdda_identify_device_cdio(p_cdio, psz_device, messagedest,
d = cdda_identify_device_cdio(p_cdio, psz_device, messagedest,
ppsz_messages);
free(psz_device);
return d;
}
}
p_cdio = cdio_open(psz_dev, DRIVER_UNKNOWN);

View File

@@ -1,5 +1,5 @@
/*
$Id: freebsd.c,v 1.9 2005/01/22 12:51:56 rocky Exp $
$Id: freebsd.c,v 1.10 2005/01/23 05:31:03 rocky Exp $
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -27,7 +27,7 @@
# include "config.h"
#endif
static const char _rcsid[] = "$Id: freebsd.c,v 1.9 2005/01/22 12:51:56 rocky Exp $";
static const char _rcsid[] = "$Id: freebsd.c,v 1.10 2005/01/23 05:31:03 rocky Exp $";
#include "freebsd.h"
@@ -632,6 +632,7 @@ cdio_open_am_freebsd (const char *psz_orig_source_name,
#if 0
cdio_info ("source %s is a not a device", psz_orig_source_name);
#endif
free(_data);
return NULL;
}
}

View File

@@ -1,5 +1,5 @@
/*
$Id: win32.c,v 1.9 2005/01/21 15:30:11 rocky Exp $
$Id: win32.c,v 1.10 2005/01/23 05:31:03 rocky Exp $
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -26,7 +26,7 @@
# include "config.h"
#endif
static const char _rcsid[] = "$Id: win32.c,v 1.9 2005/01/21 15:30:11 rocky Exp $";
static const char _rcsid[] = "$Id: win32.c,v 1.10 2005/01/23 05:31:03 rocky Exp $";
#include <cdio/cdio.h>
#include <cdio/sector.h>
@@ -781,6 +781,7 @@ cdio_open_am_win32 (const char *psz_orig_source, const char *psz_access_mode)
#if 0
cdio_info ("source %s is a not a device", psz_orig_source);
#endif
free(_data);
return NULL;
}
}

View File

@@ -1,5 +1,5 @@
/*
$Id: _cdio_bsdi.c,v 1.6 2005/01/21 20:54:55 rocky Exp $
$Id: _cdio_bsdi.c,v 1.7 2005/01/23 05:31:03 rocky Exp $
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -27,7 +27,7 @@
# include "config.h"
#endif
static const char _rcsid[] = "$Id: _cdio_bsdi.c,v 1.6 2005/01/21 20:54:55 rocky Exp $";
static const char _rcsid[] = "$Id: _cdio_bsdi.c,v 1.7 2005/01/23 05:31:03 rocky Exp $";
#include <cdio/logging.h>
#include <cdio/sector.h>
@@ -810,6 +810,7 @@ cdio_open_bsdi (const char *psz_orig_source)
#if 0
cdio_info ("source %s is not a device", psz_orig_source);
#endif
free(_data);
return NULL;
}
}

View File

@@ -1,5 +1,5 @@
/*
$Id: _cdio_linux.c,v 1.16 2005/01/21 20:54:55 rocky Exp $
$Id: _cdio_linux.c,v 1.17 2005/01/23 05:31:03 rocky Exp $
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -27,7 +27,7 @@
# include "config.h"
#endif
static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.16 2005/01/21 20:54:55 rocky Exp $";
static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.17 2005/01/23 05:31:03 rocky Exp $";
#include <string.h>
@@ -1194,6 +1194,7 @@ cdio_open_am_linux (const char *psz_orig_source, const char *access_mode)
#if 0
cdio_info ("source %s is not a device", psz_orig_source);
#endif
free(_data);
return NULL;
}
}

View File

@@ -1,5 +1,5 @@
/*
$Id: image_common.c,v 1.6 2005/01/19 09:40:50 rocky Exp $
$Id: image_common.c,v 1.7 2005/01/23 05:31:03 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -29,6 +29,7 @@
#include "image.h"
#include "image_common.h"
#include "_cdio_stdio.h"
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
@@ -62,9 +63,11 @@ _free_image (void *p_user_data)
if (NULL == p_env) return;
for (i_track=0; i_track < p_env->gen.i_tracks; i_track++) {
free_if_notnull(p_env->tocent[i_track].filename);
free_if_notnull(p_env->tocent[i_track].isrc);
cdtext_destroy(&(p_env->tocent[i_track].cdtext));
track_info_t *p_tocent = &(p_env->tocent[i_track]);
free_if_notnull(p_tocent->filename);
free_if_notnull(p_tocent->isrc);
cdtext_destroy(&(p_tocent->cdtext));
if (p_tocent->data_source) cdio_stdio_destroy(p_tocent->data_source);
}
free_if_notnull(p_env->psz_mcn);

View File

@@ -1,5 +1,5 @@
/*
$Id: isort.c,v 1.3 2005/01/07 02:42:29 rocky Exp $
$Id: isort.c,v 1.4 2005/01/23 05:31:03 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
Copyright (C) 1998 Monty xiphmont@mit.edu
@@ -47,7 +47,7 @@ sort_alloc(long size)
ret->maxsize=size;
ret->head=calloc(65536,sizeof(sort_link *));
ret->bucketusage=malloc(65536*sizeof(long));
ret->bucketusage=calloc(1, 65536*sizeof(long));
ret->revindex=calloc(size,sizeof(sort_link));
ret->lastbucket=0;

View File

@@ -1,5 +1,5 @@
/*
$Id: p_block.c,v 1.5 2005/01/10 02:10:47 rocky Exp $
$Id: p_block.c,v 1.6 2005/01/23 05:31:03 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
Copyright (C) 1998 Monty xiphmont@mit.edu
@@ -303,10 +303,11 @@ c_insert(c_block_t *v,long pos,int16_t *b,long size)
int vs=cs(v);
if(pos<0 || pos>vs)return;
if(v->vector)
v->vector=realloc(v->vector,sizeof(int16_t)*(size+vs));
else
v->vector=malloc(sizeof(int16_t)*size);
if(v->vector) {
v->vector = realloc(v->vector,sizeof(int16_t)*(size+vs));
} else {
v->vector = calloc(1, sizeof(int16_t)*size);
}
if(pos<vs)memmove(v->vector+pos+size,v->vector+pos,
(vs-pos)*sizeof(int16_t));
@@ -349,8 +350,9 @@ c_append(c_block_t *v, int16_t *vector, long size)
/* update the vector */
if(v->vector)
v->vector=realloc(v->vector,sizeof(int16_t)*(size+vs));
else
v->vector=malloc(sizeof(int16_t)*size);
else {
v->vector=calloc(1, sizeof(int16_t)*size);
}
memcpy(v->vector+vs,vector,sizeof(int16_t)*size);
v->size+=size;

View File

@@ -1,5 +1,5 @@
/*
$Id: paranoia.c,v 1.7 2005/01/14 01:37:33 rocky Exp $
$Id: paranoia.c,v 1.8 2005/01/23 05:31:03 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
Copyright (C) 1998 Monty xiphmont@mit.edu
@@ -1211,7 +1211,7 @@ i_read_c_block(cdrom_paranoia_t *p,long beginword,long endword,
new=new_c_block(p);
}
buffer=malloc(totaltoread*CDIO_CD_FRAMESIZE_RAW);
buffer=calloc(1, totaltoread*CDIO_CD_FRAMESIZE_RAW);
sofar=0;
firstread=-1;

View File

@@ -43,7 +43,7 @@
#define SKIP_TEST_RC 77
#define MAX_SECTORS 50
uint8_t audio_buf[MAX_SECTORS][CDIO_CD_FRAMESIZE_RAW];
uint8_t audio_buf[MAX_SECTORS][CDIO_CD_FRAMESIZE_RAW] = { {0}, };
paranoia_cb_mode_t audio_status[MAX_SECTORS];
unsigned int i = 0;