changeset 247:b0f09f86378d

Fix crash with Linux supermount fstab entries (thanks Erno!)
author Sam Lantinga <slouken@libsdl.org>
date Wed, 05 Dec 2001 23:49:09 +0000
parents 7c09c9e3b0c7
children 8e47ebb7bced
files src/cdrom/linux/SDL_syscdrom.c
diffstat 1 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/cdrom/linux/SDL_syscdrom.c	Tue Nov 27 01:26:57 2001 +0000
+++ b/src/cdrom/linux/SDL_syscdrom.c	Wed Dec 05 23:49:09 2001 +0000
@@ -203,18 +203,24 @@
 			if ( strcmp(mnt_type, MNTTYPE_SUPER) == 0 ) {
 				tmp = strstr(mntent->mnt_opts, "fs=");
 				if ( tmp ) {
-					strcpy(mnt_type, tmp+strlen("fs="));
-					tmp = strchr(mnt_type, ',');
-					if ( tmp ) {
-						*tmp = '\0';
+					free(mnt_type);
+					mnt_type = strdup(tmp + strlen("fs="));
+					if ( mnt_type ) {
+						tmp = strchr(mnt_type, ',');
+						if ( tmp ) {
+							*tmp = '\0';
+						}
 					}
 				}
 				tmp = strstr(mntent->mnt_opts, "dev=");
 				if ( tmp ) {
-					strcpy(mnt_dev, tmp+strlen("dev="));
-					tmp = strchr(mnt_dev, ',');
-					if ( tmp ) {
-						*tmp = '\0';
+					free(mnt_dev);
+					mnt_dev = strdup(tmp + strlen("dev="));
+					if ( mnt_dev ) {
+						tmp = strchr(mnt_dev, ',');
+						if ( tmp ) {
+							*tmp = '\0';
+						}
 					}
 				}
 			}