File tree Expand file tree Collapse file tree 1 file changed +3
-13
lines changed Expand file tree Collapse file tree 1 file changed +3
-13
lines changed Original file line number Diff line number Diff line change @@ -226,7 +226,7 @@ bool String::changeBuffer(unsigned int maxStrLen) {
226226/* ********************************************/
227227
228228String &String::copy (const char *cstr, unsigned int length) {
229- if (!reserve (length)) {
229+ if (cstr == nullptr || !reserve (length)) {
230230 invalidate ();
231231 return *this ;
232232 }
@@ -270,12 +270,7 @@ String &String::operator=(const String &rhs) {
270270 if (this == &rhs) {
271271 return *this ;
272272 }
273- if (rhs.buffer ()) {
274- copy (rhs.buffer (), rhs.len ());
275- } else {
276- invalidate ();
277- }
278- return *this ;
273+ return copy (rhs.buffer (), rhs.len ());
279274}
280275
281276#ifdef __GXX_EXPERIMENTAL_CXX0X__
@@ -295,12 +290,7 @@ String &String::operator=(StringSumHelper &&rval) {
295290#endif
296291
297292String &String::operator =(const char *cstr) {
298- if (cstr) {
299- copy (cstr, strlen (cstr));
300- } else {
301- invalidate ();
302- }
303- return *this ;
293+ return copy (cstr, strlen (cstr));
304294}
305295
306296/* ********************************************/
You can’t perform that action at this time.
0 commit comments