File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -80,8 +80,23 @@ sp<VBRISeeker> VBRISeeker::CreateFromSource(
80
80
scale,
81
81
entrySize);
82
82
83
+ if (entrySize > 4 ) {
84
+ ALOGE (" invalid VBRI entry size: %zu" , entrySize);
85
+ return NULL ;
86
+ }
87
+
88
+ sp<VBRISeeker> seeker = new (std::nothrow) VBRISeeker;
89
+ if (seeker == NULL ) {
90
+ ALOGW (" Couldn't allocate VBRISeeker" );
91
+ return NULL ;
92
+ }
93
+
83
94
size_t totalEntrySize = numEntries * entrySize;
84
- uint8_t *buffer = new uint8_t [totalEntrySize];
95
+ uint8_t *buffer = new (std::nothrow) uint8_t [totalEntrySize];
96
+ if (!buffer) {
97
+ ALOGW (" Couldn't allocate %zu bytes" , totalEntrySize);
98
+ return NULL ;
99
+ }
85
100
86
101
n = source->readAt (pos + sizeof (vbriHeader), buffer, totalEntrySize);
87
102
if (n < (ssize_t )totalEntrySize) {
@@ -91,7 +106,6 @@ sp<VBRISeeker> VBRISeeker::CreateFromSource(
91
106
return NULL ;
92
107
}
93
108
94
- sp<VBRISeeker> seeker = new VBRISeeker;
95
109
seeker->mBasePos = post_id3_pos + frameSize;
96
110
// only update mDurationUs if the calculated duration is valid (non zero)
97
111
// otherwise, leave duration at -1 so that getDuration() and getOffsetForTime()
You can’t perform that action at this time.
0 commit comments