summaryrefslogtreecommitdiff
path: root/usr.bin/cdio/cddb.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/cdio/cddb.c')
-rw-r--r--usr.bin/cdio/cddb.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/usr.bin/cdio/cddb.c b/usr.bin/cdio/cddb.c
index 9f90acee75a..d7e8e75218d 100644
--- a/usr.bin/cdio/cddb.c
+++ b/usr.bin/cdio/cddb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cddb.c,v 1.4 2002/04/18 22:17:04 espie Exp $ */
+/* $OpenBSD: cddb.c,v 1.5 2002/12/14 21:28:08 espie Exp $ */
/*
* Copyright (c) 2002 Marc Espie.
*
@@ -46,7 +46,7 @@ int parse_connect_to(const char *, const char *);
char * get_line(FILE *);
char * get_answer(FILE *);
void verify_track_names(char **, int, struct cd_toc_entry *);
-char * safe_copy(const char *);
+void safe_copy(char **, const char *);
unsigned long
cddb_sum(unsigned long v)
@@ -99,11 +99,21 @@ send_query(FILE *f, int n, struct cd_toc_entry *e)
#define MAXSIZE 256
char copy_buffer[MAXSIZE];
-char *
-safe_copy(const char *title)
+void
+safe_copy(char **p, const char *title)
{
strnvis(copy_buffer, title, MAXSIZE-1, VIS_TAB|VIS_NL);
- return strdup(copy_buffer);
+ if (*p == NULL)
+ *p = strdup(copy_buffer);
+ else {
+ char *n = malloc(strlen(*p) + strlen(copy_buffer) + 1);
+ if (n == NULL)
+ return;
+ strcpy(n, *p);
+ strcat(n, copy_buffer);
+ free(*p);
+ *p = n;
+ }
}
int
@@ -342,7 +352,7 @@ cddb(const char *host_port, int n, struct cd_toc_entry *e, char *arg)
continue;
if (k >= n)
continue;
- result[k] = safe_copy(end);
+ safe_copy(&result[k], end);
}
fprintf(cout, "QUIT\r\n");
verify_track_names(result, n, e);