timezone: Do not access already released memory
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Wed, 31 Aug 2011 08:42:44 +0000 (11:42 +0300)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 12 Sep 2011 09:40:48 +0000 (11:40 +0200)
closedir() releases the filename but we were accessing it later.

src/timezone.c

index 08f904f..1234622 100644 (file)
@@ -185,9 +185,10 @@ static char *find_origin(void *src_map, struct stat *src_st,
                                                        subpath, d->d_name);
 
                        if (compare_file(src_map, src_st, pathname) == 0) {
-                               closedir(dir);
-                               return g_strdup_printf("%s/%s",
+                               str = g_strdup_printf("%s/%s",
                                                        subpath, d->d_name);
+                               closedir(dir);
+                               return str;
                        }
                        break;
                case DT_DIR: