Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(763)

Side by Side Diff: third_party/WebKit/Source/wtf/ArrayBuffer.cpp

Issue 1414553002: Fix out-of-memory crashes related to ArrayBuffer allocation Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase+more tweaks Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 bool allViewsAreNeuterable = true; 44 bool allViewsAreNeuterable = true;
45 for (ArrayBufferView* i = m_firstView; i; i = i->m_nextView) { 45 for (ArrayBufferView* i = m_firstView; i; i = i->m_nextView) {
46 if (!i->isNeuterable()) 46 if (!i->isNeuterable())
47 allViewsAreNeuterable = false; 47 allViewsAreNeuterable = false;
48 } 48 }
49 49
50 if (allViewsAreNeuterable) { 50 if (allViewsAreNeuterable) {
51 m_contents.transfer(result); 51 m_contents.transfer(result);
52 } else { 52 } else {
53 m_contents.copyTo(result); 53 m_contents.copyTo(result, ArrayBufferContents::NullDataIfOutOfMemory);
54 if (!result.data()) 54 if (!result.data())
55 return false; 55 return false;
56 } 56 }
57 57
58 while (m_firstView) { 58 while (m_firstView) {
59 ArrayBufferView* current = m_firstView; 59 ArrayBufferView* current = m_firstView;
60 removeView(current); 60 removeView(current);
61 if (allViewsAreNeuterable || current->isNeuterable()) 61 if (allViewsAreNeuterable || current->isNeuterable())
62 current->neuter(); 62 current->neuter();
63 } 63 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 if (view->m_nextView) 97 if (view->m_nextView)
98 view->m_nextView->m_prevView = view->m_prevView; 98 view->m_nextView->m_prevView = view->m_prevView;
99 if (view->m_prevView) 99 if (view->m_prevView)
100 view->m_prevView->m_nextView = view->m_nextView; 100 view->m_prevView->m_nextView = view->m_nextView;
101 if (m_firstView == view) 101 if (m_firstView == view)
102 m_firstView = view->m_nextView; 102 m_firstView = view->m_nextView;
103 view->m_prevView = view->m_nextView = 0; 103 view->m_prevView = view->m_nextView = 0;
104 } 104 }
105 105
106 } 106 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/ArrayBuffer.h ('k') | third_party/WebKit/Source/wtf/ArrayBufferBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698