From 0c3e17a4ec5749f53e6f181fd9bde5823bac2d9c Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sat, 29 Nov 2003 17:44:30 +0000 Subject: [PATCH] Fix sensors segfault on bus freeing (sysfs). git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@2111 7894878c-1315-0410-8ee3-d5d059ff63e0 --- lib/proc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/proc.c b/lib/proc.c index d8e21476..21c8f654 100644 --- a/lib/proc.c +++ b/lib/proc.c @@ -213,17 +213,23 @@ int sensors_read_proc_bus(void) entry.adapter=strdup(x); if(!strncmp(x, "ISA ", 4)) { entry.number = SENSORS_CHIP_NAME_BUS_ISA; - entry.algorithm = "ISA bus algorithm"; + entry.algorithm = strdup("ISA bus algorithm"); } else if(!sscanf(de->d_name, "i2c-%d", &entry.number)) { entry.number = SENSORS_CHIP_NAME_BUS_DUMMY; - entry.algorithm = "Dummy bus algorithm"; + entry.algorithm = strdup("Dummy bus algorithm"); } else - entry.algorithm = "Unavailable from sysfs"; + entry.algorithm = strdup("Unavailable from sysfs"); + if (entry.algorithm == NULL) + goto FAT_ERROR_SYS; add_proc_bus(&entry); } } closedir(dir); return 0; +FAT_ERROR_SYS: + sensors_fatal_error("sensors_read_proc_bus", "Allocating entry"); + closedir(dir); + return -SENSORS_ERR_PROC; } proc: