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

Side by Side Diff: remoting/host/win/wts_terminal_monitor.cc

Issue 14205019: Do not access memory freed by WTSFreeMemory(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/host/win/wts_terminal_monitor.h" 5 #include "remoting/host/win/wts_terminal_monitor.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <winternl.h> 8 #include <winternl.h>
9 #include <wtsapi32.h> 9 #include <wtsapi32.h>
10 10
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 DWORD session_info_count; 153 DWORD session_info_count;
154 if (!WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE, 0, 1, &session_info, 154 if (!WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE, 0, 1, &session_info,
155 &session_info_count)) { 155 &session_info_count)) {
156 LOG_GETLASTERROR(ERROR) << "Failed to enumerate all sessions"; 156 LOG_GETLASTERROR(ERROR) << "Failed to enumerate all sessions";
157 return kInvalidSessionId; 157 return kInvalidSessionId;
158 } 158 }
159 for (DWORD i = 0; i < session_info_count; ++i) { 159 for (DWORD i = 0; i < session_info_count; ++i) {
160 net::IPEndPoint endpoint; 160 net::IPEndPoint endpoint;
161 if (GetEndpointForSessionId(session_info[i].SessionId, &endpoint) && 161 if (GetEndpointForSessionId(session_info[i].SessionId, &endpoint) &&
162 endpoint == client_endpoint) { 162 endpoint == client_endpoint) {
163 uint32 session_id = session_info[i].SessionId;
163 WTSFreeMemory(session_info); 164 WTSFreeMemory(session_info);
164 return session_info[i].SessionId; 165 return session_id;
165 } 166 }
166 } 167 }
167 168
168 // |client_endpoint| is not associated with any session. 169 // |client_endpoint| is not associated with any session.
169 WTSFreeMemory(session_info); 170 WTSFreeMemory(session_info);
170 return kInvalidSessionId; 171 return kInvalidSessionId;
171 } 172 }
172 173
173 WtsTerminalMonitor::WtsTerminalMonitor() { 174 WtsTerminalMonitor::WtsTerminalMonitor() {
174 } 175 }
175 176
176 } // namespace remoting 177 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698