diff --git a/apps/app_dial.c b/apps/app_dial.c
index 035604e6786acd6584330c79d81dc96280affa89..e566f58a3c06653853f39958d3d5c59e05e3998e 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -1846,7 +1846,7 @@ static int retrydial_exec(struct ast_channel *chan, void *data)
 
 	if ((dialdata = strchr(announce, '|'))) {
 		*dialdata++ = '\0';
-		if ((sleep = atoi(dialdata))) {
+		if (sscanf(dialdata, "%d", &sleep) == 1) {
 			sleep *= 1000;
 		} else {
 			ast_log(LOG_ERROR, "%s requires the numerical argument <sleep>\n",rapp);
@@ -1854,7 +1854,7 @@ static int retrydial_exec(struct ast_channel *chan, void *data)
 		}
 		if ((dialdata = strchr(dialdata, '|'))) {
 			*dialdata++ = '\0';
-			if (!(loops = atoi(dialdata))) {
+			if (sscanf(dialdata, "%d", &loops) != 1) {
 				ast_log(LOG_ERROR, "%s requires the numerical argument <loops>\n",rapp);
 				goto done;
 			}