Loading media/libstagefright/id3/ID3.cpp +28 −15 Original line number Diff line number Diff line Loading @@ -77,7 +77,10 @@ ID3::ID3(const uint8_t *data, size_t size, bool ignoreV1) mFirstFrameOffset(0), mVersion(ID3_UNKNOWN), mRawSize(0) { sp<MemorySource> source = new MemorySource(data, size); sp<MemorySource> source = new (std::nothrow) MemorySource(data, size); if (source == NULL) return; mIsValid = parseV2(source, 0); Loading Loading @@ -555,11 +558,15 @@ void ID3::Iterator::getstring(String8 *id, bool otherdata) const { const char16_t *framedata = (const char16_t *) (frameData + 1); char16_t *framedatacopy = NULL; #if BYTE_ORDER == LITTLE_ENDIAN framedatacopy = new char16_t[len]; if (len > 0) { framedatacopy = new (std::nothrow) char16_t[len]; if (framedatacopy != NULL) { for (int i = 0; i < len; i++) { framedatacopy[i] = bswap_16(framedata[i]); } framedata = framedatacopy; } } #endif id->setTo(framedata, len); if (framedatacopy != NULL) { Loading @@ -573,12 +580,16 @@ void ID3::Iterator::getstring(String8 *id, bool otherdata) const { char16_t *framedatacopy = NULL; if (*framedata == 0xfffe) { // endianness marker doesn't match host endianness, convert framedatacopy = new char16_t[len]; if (len > 0) { framedatacopy = new (std::nothrow) char16_t[len]; if (framedatacopy != NULL) { for (int i = 0; i < len; i++) { framedatacopy[i] = bswap_16(framedata[i]); } framedata = framedatacopy; } } } // If the string starts with an endianness marker, skip it if (*framedata == 0xfeff) { framedata++; Loading @@ -593,14 +604,16 @@ void ID3::Iterator::getstring(String8 *id, bool otherdata) const { break; } } if (eightBit) { if (eightBit && len > 0) { // collapse to 8 bit, then let the media scanner client figure out the real encoding char *frame8 = new char[len]; char *frame8 = new (std::nothrow) char[len]; if (frame8 != NULL) { for (int i = 0; i < len; i++) { frame8[i] = framedata[i]; } id->setTo(frame8, len); delete [] frame8; } } else { id->setTo(framedata, len); } Loading Loading
media/libstagefright/id3/ID3.cpp +28 −15 Original line number Diff line number Diff line Loading @@ -77,7 +77,10 @@ ID3::ID3(const uint8_t *data, size_t size, bool ignoreV1) mFirstFrameOffset(0), mVersion(ID3_UNKNOWN), mRawSize(0) { sp<MemorySource> source = new MemorySource(data, size); sp<MemorySource> source = new (std::nothrow) MemorySource(data, size); if (source == NULL) return; mIsValid = parseV2(source, 0); Loading Loading @@ -555,11 +558,15 @@ void ID3::Iterator::getstring(String8 *id, bool otherdata) const { const char16_t *framedata = (const char16_t *) (frameData + 1); char16_t *framedatacopy = NULL; #if BYTE_ORDER == LITTLE_ENDIAN framedatacopy = new char16_t[len]; if (len > 0) { framedatacopy = new (std::nothrow) char16_t[len]; if (framedatacopy != NULL) { for (int i = 0; i < len; i++) { framedatacopy[i] = bswap_16(framedata[i]); } framedata = framedatacopy; } } #endif id->setTo(framedata, len); if (framedatacopy != NULL) { Loading @@ -573,12 +580,16 @@ void ID3::Iterator::getstring(String8 *id, bool otherdata) const { char16_t *framedatacopy = NULL; if (*framedata == 0xfffe) { // endianness marker doesn't match host endianness, convert framedatacopy = new char16_t[len]; if (len > 0) { framedatacopy = new (std::nothrow) char16_t[len]; if (framedatacopy != NULL) { for (int i = 0; i < len; i++) { framedatacopy[i] = bswap_16(framedata[i]); } framedata = framedatacopy; } } } // If the string starts with an endianness marker, skip it if (*framedata == 0xfeff) { framedata++; Loading @@ -593,14 +604,16 @@ void ID3::Iterator::getstring(String8 *id, bool otherdata) const { break; } } if (eightBit) { if (eightBit && len > 0) { // collapse to 8 bit, then let the media scanner client figure out the real encoding char *frame8 = new char[len]; char *frame8 = new (std::nothrow) char[len]; if (frame8 != NULL) { for (int i = 0; i < len; i++) { frame8[i] = framedata[i]; } id->setTo(frame8, len); delete [] frame8; } } else { id->setTo(framedata, len); } Loading