Add guard around get_mcn for null p_cdio.

This commit is contained in:
R. Bernstein
2012-04-15 00:49:01 -04:00
parent be5e4108ce
commit 58400f03b9
5 changed files with 65 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
/* /*
Copyright (C) 2003, 2004, 2005, 2008, 2011 Copyright (C) 2003, 2004, 2005, 2008, 2011, 2012
Rocky Bernstein <rocky@gnu.org> Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
@@ -124,7 +124,7 @@ cdio_get_discmode (CdIo_t *cd_obj)
char * char *
cdio_get_mcn (const CdIo_t *p_cdio) cdio_get_mcn (const CdIo_t *p_cdio)
{ {
if (p_cdio->op.get_mcn) { if (p_cdio && p_cdio->op.get_mcn) {
return p_cdio->op.get_mcn (p_cdio->env); return p_cdio->op.get_mcn (p_cdio->env);
} else { } else {
return NULL; return NULL;

View File

@@ -9,6 +9,7 @@
/bincue /bincue
/bincue /bincue
/bincue.c /bincue.c
/cdda
/cdrdao /cdrdao
/cdrdao.c /cdrdao.c
/follow_symlink /follow_symlink

View File

@@ -24,6 +24,10 @@ bincue_SOURCES = helper.c bincue.c
bincue_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV) bincue_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
bincue_CFLAGS = -DDATA_DIR=\"$(DATA_DIR)\" bincue_CFLAGS = -DDATA_DIR=\"$(DATA_DIR)\"
cdda_SOURCES = helper.c cdda.c
cdda_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
cdda_CFLAGS = -DDATA_DIR=\"$(DATA_DIR)\"
cdrdao_SOURCES = helper.c cdrdao.c cdrdao_SOURCES = helper.c cdrdao.c
cdrdao_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV) cdrdao_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
cdrdao_CFLAGS = -DDATA_DIR=\"$(DATA_DIR)\" cdrdao_CFLAGS = -DDATA_DIR=\"$(DATA_DIR)\"
@@ -58,7 +62,7 @@ win32_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
win32_CFLAGS = -DDATA_DIR=\"$(DATA_DIR)\" win32_CFLAGS = -DDATA_DIR=\"$(DATA_DIR)\"
check_PROGRAMS = \ check_PROGRAMS = \
abs_path bincue cdrdao freebsd gnu_linux \ abs_path bincue cdda cdrdao freebsd gnu_linux \
mmc_read mmc_write nrg \ mmc_read mmc_write nrg \
osx realpath solaris win32 osx realpath solaris win32

56
test/driver/cdda.c Normal file
View File

@@ -0,0 +1,56 @@
/* -*- C -*-
Copyright (C) 2012 Rocky Bernstein <rocky@gnu.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Unit test for cdda-like things lib/driver/disc.c
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include "helper.h"
int
main(int argc, const char *argv[])
{
char *mcn = cdio_get_mcn(NULL);
cdio_log_set_handler(log_handler);
cdio_loglevel_default = (argc > 1) ? CDIO_LOG_DEBUG : CDIO_LOG_INFO;
/* Had a bug in not testing for null p_cdio with cdio_get_mcn. */
mcn = cdio_get_mcn(NULL);
if (mcn != NULL) {
printf("Should have gotten NULL for MCN for cdio object\n");
return 1;
}
return 0;
}

View File

@@ -1,5 +1,5 @@
/* -*- C -*- /* -*- C -*-
Copyright (C) 2009, 2010 Rocky Bernstein <rocky@gnu.org> Copyright (C) 2009, 2010, 2012 Rocky Bernstein <rocky@gnu.org>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -20,7 +20,6 @@
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#define __CDIO_CONFIG_H__ 1
#endif #endif
#ifdef HAVE_STDIO_H #ifdef HAVE_STDIO_H