diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index e5bce131ad13cbbd53cb41899c228852167b1949..8cee69be5337fef4b3a1e243585553ed6e507aa1 100755
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -713,8 +713,10 @@ static int moh_scan_files(struct mohclass *class) {
 		if (!S_ISREG(statbuf.st_mode))
 			continue;
 
-		if ((ext = strrchr(filepath, '.')))
+		if ((ext = strrchr(filepath, '.'))) {
 			*ext = '\0';
+			ext++;
+		}
 
 		/* check to see if this file's format can be opened */
 		if (ast_fileexists(filepath, ext, NULL) == -1)