File tree 1 file changed +3
-13
lines changed
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) {
226
226
/* ********************************************/
227
227
228
228
String &String::copy (const char *cstr, unsigned int length) {
229
- if (!reserve (length)) {
229
+ if (cstr == nullptr || !reserve (length)) {
230
230
invalidate ();
231
231
return *this ;
232
232
}
@@ -270,12 +270,7 @@ String &String::operator=(const String &rhs) {
270
270
if (this == &rhs) {
271
271
return *this ;
272
272
}
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 ());
279
274
}
280
275
281
276
#ifdef __GXX_EXPERIMENTAL_CXX0X__
@@ -295,12 +290,7 @@ String &String::operator=(StringSumHelper &&rval) {
295
290
#endif
296
291
297
292
String &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));
304
294
}
305
295
306
296
/* ********************************************/
You can’t perform that action at this time.
0 commit comments