summaryrefslogtreecommitdiff
path: root/arm-wt-22k
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2019-05-31 14:05:37 -0700
committerMarco Nelissen <marcone@google.com>2019-05-31 14:16:18 -0700
commit41d0162ec71e6fc51f62625b4aabba6f6658f8e6 (patch)
tree02e860df214753eb5f72630c2ffaf3063d0008a4 /arm-wt-22k
parent108a3de880f3ea42174fc93b181d5a26d542fe93 (diff)
downloadsonivox-41d0162ec71e6fc51f62625b4aabba6f6658f8e6.tar.gz
Fix infinite loop on partial rtttl note
If the loop in an infinitely-looped file contained only a partial note, it would busy-loop forever. Bug: 134088615 Test: manual Change-Id: I5c7d5f616919b4cd2e68de62f5d8a433cd4f990b
Diffstat (limited to 'arm-wt-22k')
-rw-r--r--arm-wt-22k/lib_src/eas_rtttl.c6
-rw-r--r--arm-wt-22k/lib_src/eas_rtttldata.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/arm-wt-22k/lib_src/eas_rtttl.c b/arm-wt-22k/lib_src/eas_rtttl.c
index d8253fb..34a9029 100644
--- a/arm-wt-22k/lib_src/eas_rtttl.c
+++ b/arm-wt-22k/lib_src/eas_rtttl.c
@@ -334,8 +334,12 @@ static EAS_RESULT RTTTL_Event (S_EAS_DATA *pEASData, EAS_VOID_PTR pInstData, EAS
}
/* loop back to start of notes */
+ if (pData->notePlayedSinceRepeat == 0) {
+ return EAS_ERROR_FILE_FORMAT;
+ }
if ((result = EAS_HWFileSeek(pEASData->hwInstData, pData->fileHandle, pData->repeatOffset)) != EAS_SUCCESS)
return result;
+ pData->notePlayedSinceRepeat = 0;
continue;
}
@@ -444,6 +448,7 @@ static EAS_RESULT RTTTL_Event (S_EAS_DATA *pEASData, EAS_VOID_PTR pInstData, EAS
/* end of event */
else if ((c == ',') && note)
{
+ pData->notePlayedSinceRepeat = 1;
/* handle note events */
if (note != RTTTL_REST)
@@ -1102,6 +1107,7 @@ static EAS_RESULT RTTTL_ParseHeader (S_EAS_DATA *pEASData, S_RTTTL_DATA* pData,
if ((result = EAS_HWFilePos(pEASData->hwInstData, pData->fileHandle, &pData->repeatOffset)) != EAS_SUCCESS)
return result;
+ pData->notePlayedSinceRepeat = 0;
return EAS_SUCCESS;
}
diff --git a/arm-wt-22k/lib_src/eas_rtttldata.h b/arm-wt-22k/lib_src/eas_rtttldata.h
index 31dd522..1901670 100644
--- a/arm-wt-22k/lib_src/eas_rtttldata.h
+++ b/arm-wt-22k/lib_src/eas_rtttldata.h
@@ -57,6 +57,7 @@ typedef struct
EAS_I32 restTicks; /* ticks to rest after current note */
EAS_I32 repeatOffset; /* file offset to start of repeat section */
EAS_U8 repeatCount; /* repeat counter */
+ EAS_U8 notePlayedSinceRepeat; /* indicates if any work done since last repeat */
EAS_I8 dataByte; /* storage for characters that are "put back" */
EAS_U8 state; /* current state EAS_STATE_XXXX */
EAS_I8 style; /* from STYLE */