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

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/memfs/mem_fs_node.cc

Issue 605433003: [NaCl SDK] nacl_io: Fix gaping memory leaks in memfs and htmlfs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup_nacl_io
Patch Set: Created 6 years, 3 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
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.cc ('k') | 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef __STDC_LIMIT_MACROS 5 #ifndef __STDC_LIMIT_MACROS
6 #define __STDC_LIMIT_MACROS 6 #define __STDC_LIMIT_MACROS
7 #endif 7 #endif
8 8
9 #include "nacl_io/memfs/mem_fs_node.h" 9 #include "nacl_io/memfs/mem_fs_node.h"
10 10
(...skipping 19 matching lines...) Expand all
30 } // namespace 30 } // namespace
31 31
32 MemFsNode::MemFsNode(Filesystem* filesystem) 32 MemFsNode::MemFsNode(Filesystem* filesystem)
33 : Node(filesystem), 33 : Node(filesystem),
34 data_(NULL), 34 data_(NULL),
35 data_capacity_(0) { 35 data_capacity_(0) {
36 SetType(S_IFREG); 36 SetType(S_IFREG);
37 } 37 }
38 38
39 MemFsNode::~MemFsNode() { 39 MemFsNode::~MemFsNode() {
40 free(data_);
40 } 41 }
41 42
42 Error MemFsNode::Read(const HandleAttr& attr, 43 Error MemFsNode::Read(const HandleAttr& attr,
43 void* buf, 44 void* buf,
44 size_t count, 45 size_t count,
45 int* out_bytes) { 46 int* out_bytes) {
46 *out_bytes = 0; 47 *out_bytes = 0;
47 48
48 AUTO_LOCK(node_lock_); 49 AUTO_LOCK(node_lock_);
49 if (count == 0) 50 if (count == 0)
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 data_capacity_ = new_capacity; 117 data_capacity_ = new_capacity;
117 } 118 }
118 119
119 if (new_length > stat_.st_size) 120 if (new_length > stat_.st_size)
120 memset(data_ + stat_.st_size, 0, new_length - stat_.st_size); 121 memset(data_ + stat_.st_size, 0, new_length - stat_.st_size);
121 stat_.st_size = new_length; 122 stat_.st_size = new_length;
122 return 0; 123 return 0;
123 } 124 }
124 125
125 } // namespace nacl_io 126 } // namespace nacl_io
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/httpfs/http_fs_node.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698