Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: compiled/String.h

Issue 29680706: Noissue - zero length OwnedString is valid. (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Jan. 26, 2018, 8:33 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« 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 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 mBuf = new value_type[length()]; 288 mBuf = new value_type[length()];
289 annotate_address(mBuf, "String"); 289 annotate_address(mBuf, "String");
290 } 290 }
291 else 291 else
292 mBuf = nullptr; 292 mBuf = nullptr;
293 } 293 }
294 294
295 explicit OwnedString(const String& str) 295 explicit OwnedString(const String& str)
296 : OwnedString(str.length()) 296 : OwnedString(str.length())
297 { 297 {
298 if (length()) 298 if (!str.is_invalid() && !length())
299 mLen = length() | READ_WRITE;
300 else if (length())
299 std::memcpy(mBuf, str.mBuf, sizeof(value_type) * length()); 301 std::memcpy(mBuf, str.mBuf, sizeof(value_type) * length());
300 } 302 }
301 303
302 OwnedString(const OwnedString& str) 304 OwnedString(const OwnedString& str)
303 : OwnedString(static_cast<const String&>(str)) 305 : OwnedString(static_cast<const String&>(str))
304 { 306 {
305 } 307 }
306 308
307 explicit OwnedString(const value_type* str, size_type len) 309 explicit OwnedString(const value_type* str, size_type len)
308 : OwnedString(DependentString(str, len)) 310 : OwnedString(DependentString(str, len))
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 if (negative) 413 if (negative)
412 mBuf[pos++] = '-'; 414 mBuf[pos++] = '-';
413 415
414 for (int i = size - 1; i >= 0; i--) 416 for (int i = size - 1; i >= 0; i--)
415 { 417 {
416 mBuf[pos + i] = '0' + (num % 10); 418 mBuf[pos + i] = '0' + (num % 10);
417 num /= 10; 419 num /= 10;
418 } 420 }
419 } 421 }
420 }; 422 };
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