Check to make sure opendir works in chan_iax2.c (bug 1283)
authorJames Golovich <james@gnuinter.net>
Tue, 23 Mar 2004 21:42:35 +0000 (21:42 +0000)
committerJames Golovich <james@gnuinter.net>
Tue, 23 Mar 2004 21:42:35 +0000 (21:42 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2539 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_iax2.c

index 59490d8..7050e7d 100755 (executable)
@@ -1051,16 +1051,19 @@ static void reload_firmware(void)
        /* Now that we've freed them, load the new ones */
        snprintf(dir, sizeof(dir), "%s/firmware/iax", (char *)ast_config_AST_VAR_DIR);
        fwd = opendir(dir);
-       while((de = readdir(fwd))) {
-               if (de->d_name[0] != '.') {
-                       snprintf(fn, sizeof(fn), "%s/%s", dir, de->d_name);
-                       if (!try_firmware(fn)) {
-                               if (option_verbose > 1)
-                                       ast_verbose(VERBOSE_PREFIX_2 "Loaded firmware '%s'\n", de->d_name);
+       if (fwd) {
+               while((de = readdir(fwd))) {
+                       if (de->d_name[0] != '.') {
+                               snprintf(fn, sizeof(fn), "%s/%s", dir, de->d_name);
+                               if (!try_firmware(fn)) {
+                                       if (option_verbose > 1)
+                                               ast_verbose(VERBOSE_PREFIX_2 "Loaded firmware '%s'\n", de->d_name);
+                               }
                        }
                }
-       }
-       closedir(fwd);
+               closedir(fwd);
+       } else 
+               ast_log(LOG_WARNING, "Error opening firmware directory '%s': %s\n", dir, strerror(errno));
 
        /* Clean up leftovers */
        cur = waresl.wares;