Buggy code:
public class Uploader extends FileActivity implements View . OnClickListener , OnItemClickListener , CopyTmpFileAsyncTask . OnCopyTmpFileTaskListener { private static final String TAG = Uploader . class . getSimpleName ( ) ; private AccountManager mAccountManager ; private Stack < String > mParents ; private ArrayList < Parcelable > mStreamsToUpload ; private boolean mCreateDir ; private String mUploadPath ; private OCFile mFile ; private Uploader . SyncBroadcastReceiver mSyncBroadcastReceiver ; private boolean mSyncInProgress = false ; private boolean mAccountSelected ; private boolean mAccountSelectionShowing ; private ArrayList < String > mRemoteCacheData ; private int mNumCacheFile ; private static final int DIALOG_NO_ACCOUNT = 0 ; private static final int DIALOG_WAITING = 1 ; private static final int DIALOG_NO_STREAM = 2 ; private static final int DIALOG_MULTIPLE_ACCOUNT = 3 ; private static final int DIALOG_STREAM_UNKNOWN = 4 ; private static final int REQUEST_CODE__SETUP_ACCOUNT = ( REQUEST_CODE__LAST_SHARED ) + 1 ; private static final String KEY_PARENTS = "PARENTS" ; private static final String KEY_FILE = "FILE" ; private static final String KEY_ACCOUNT_SELECTED = "ACCOUNT_SELECTED" ; private static final String KEY_ACCOUNT_SELECTION_SHOWING = "ACCOUNT_SELECTION_SHOWING" ; private static final String KEY_NUM_CACHE_FILE = "NUM_CACHE_FILE" ; private static final String KEY_REMOTE_CACHE_DATA = "REMOTE_CACHE_DATA" ; private static final String DIALOG_WAIT_COPY_FILE = "DIALOG_WAIT_COPY_FILE" ; @ Override protected void onCreate ( Bundle savedInstanceState ) { } @ Override protected void setAccount ( Account account , boolean savedAccount ) { } @ Override protected void onAccountSet ( boolean stateWasRecovered ) { } @ Override protected void onSaveInstanceState ( Bundle outState ) { } @ Override protected void onDestroy ( ) { } @ Override protected Dialog onCreateDialog ( final int id ) { } class a implements OnClickListener { String mPath ; EditText mDirname ; public a ( String path , EditText dirname ) { } @ Override public void onClick ( DialogInterface dialog , int which ) { } } @ Override public void onBackPressed ( ) { } @ Override public void onItemClick ( AdapterView < ? > parent , View view , int position , long id ) { } @ Override public void onClick ( View v ) { } @ Override protected void onActivityResult ( int requestCode , int resultCode , Intent data ) { } private void populateDirectoryList ( ) { } @ Override public void onSavedCertificate ( ) { } private void startSyncFolderOperation ( OCFile folder ) { } private String generatePath ( Stack < String > dirs ) { } private void prepareStreamsToUpload ( ) { } private boolean somethingToUpload ( ) { } @ SuppressLint ( "NewApi" ) public void uploadFiles ( ) { try { for ( Parcelable mStream : mStreamsToUpload ) { Uri uri = ( ( Uri ) ( mStream ) ) ; String [ ] columnValues ; String displayName = null ; String filePath = "" ; if ( uri != null ) { if ( uri . getScheme ( ) . equals ( "content" ) ) { String mimeType = getContentResolver ( ) . getType ( uri ) ; if ( mimeType . contains ( "image" ) ) { columnValues = getColumnsValues ( uri , DISPLAY_NAME ) ; } else if ( mimeType . contains ( "video" ) ) { columnValues = getColumnsValues ( uri , DISPLAY_NAME ) ; } else if ( mimeType . contains ( "audio" ) ) { columnValues = getColumnsValues ( uri , DISPLAY_NAME ) ; } else { columnValues = getColumnsValues ( uri , DISPLAY_NAME ) ; } displayName = ( columnValues != null ) ? columnValues [ 0 ] : uri . getLastPathSegment ( ) . replaceAll ( "\\s" , "" ) ; int index = displayName . lastIndexOf ( "." ) ; <START_BUG> if ( ( index == ( - 1 ) ) || ( ( MimeTypeMap . getSingleton ( ) . getMimeTypeFromExtension ( displayName . substring ( index ) ) ) == null ) ) { <END_BUG> String extension = MimeTypeMap . getSingleton ( ) . getExtensionFromMimeType ( mimeType ) ; displayName += ( extension != null ) ? "." + extension : "" ; } } else if ( uri . getScheme ( ) . equals ( "file" ) ) { displayName = uri . getLastPathSegment ( ) ; } } if ( displayName != null ) { filePath = ( mUploadPath ) + displayName ; mRemoteCacheData . add ( filePath ) ; CopyTmpFileAsyncTask copyTask = new CopyTmpFileAsyncTask ( this ) ; Object [ ] params = new Object [ ] { uri , filePath , ( mRemoteCacheData . size ( ) ) - 1 , getAccount ( ) . name , getContentResolver ( ) } ; ( mNumCacheFile ) ++ ; showWaitingCopyDialog ( ) ; copyTask . execute ( params ) ; } else { throw new SecurityException ( ) ; } SharedPreferences . Editor appPrefs = PreferenceManager . getDefaultSharedPreferences ( getApplicationContext ( ) ) . edit ( ) ; appPrefs . putString ( "last_upload_path" , mUploadPath ) ; appPrefs . apply ( ) ; finish ( ) ; } } catch ( SecurityException e ) { showDialog ( Uploader . DIALOG_STREAM_UNKNOWN ) ; } } private String [ ] getColumnsValues ( Uri uri , String ... columns ) { } @ Override public void onRemoteOperationFinish ( RemoteOperation operation , RemoteOperationResult result ) { } private void onCreateFolderOperationFinish ( CreateFolderOperation operation , RemoteOperationResult result ) { } private void initTargetFolder ( ) { } @ Override public boolean onCreateOptionsMenu ( Menu menu ) { } @ Override public boolean onOptionsItemSelected ( MenuItem item ) { } private OCFile getCurrentFolder ( ) { } private void browseToRoot ( ) { } private class SyncBroadcastReceiver extends BroadcastReceiver { @ Override public void onReceive ( Context context , Intent intent ) { } } @ Override public void onTmpFileCopied ( String result , int index ) { } public void showWaitingCopyDialog ( ) { } public void dismissWaitingCopyDialog ( ) { } }

Fix:
if ( ( index == ( - 1 ) ) || ( ( MimeTypeMap . getSingleton ( ) . getMimeTypeFromExtension ( displayName . substring ( ( index + 1 ) ) ) ) == null ) ) {