gravatar
deba@inf.elte.hu
deba@inf.elte.hu
Fix memory leak hazard If the constructor throws an exception, it should deallocate each dynamically allocated memory.
0 2 0
default
2 files changed with 56 insertions and 14 deletions:
↑ Collapse diff ↑
Show white space 2 line context
... ...
@@ -519,3 +519,6 @@
519 519
        _skip_nodes(false), _skip_arcs(false) {
520
      if (!(*_is)) throw IoError("Cannot open file", fn);
520
      if (!(*_is)) {
521
        delete _is;
522
        throw IoError("Cannot open file", fn);
523
      }
521 524
    }
... ...
@@ -531,3 +534,6 @@
531 534
        _skip_nodes(false), _skip_arcs(false) {
532
      if (!(*_is)) throw IoError("Cannot open file", fn);
535
      if (!(*_is)) {
536
        delete _is;
537
        throw IoError("Cannot open file", fn);
538
      }
533 539
    }
... ...
@@ -1310,3 +1316,6 @@
1310 1316
        _skip_nodes(false), _skip_edges(false) {
1311
      if (!(*_is)) throw IoError("Cannot open file", fn);
1317
      if (!(*_is)) {
1318
        delete _is;
1319
        throw IoError("Cannot open file", fn);
1320
      }
1312 1321
    }
... ...
@@ -1322,3 +1331,6 @@
1322 1331
        _skip_nodes(false), _skip_edges(false) {
1323
      if (!(*_is)) throw IoError("Cannot open file", fn);
1332
      if (!(*_is)) {
1333
        delete _is;
1334
        throw IoError("Cannot open file", fn);
1335
      }
1324 1336
    }
... ...
@@ -2096,3 +2108,6 @@
2096 2108
        _filename(fn) {
2097
      if (!(*_is)) throw IoError("Cannot open file", fn);
2109
      if (!(*_is)) {
2110
        delete _is;
2111
        throw IoError("Cannot open file", fn);
2112
      }
2098 2113
    }
... ...
@@ -2105,3 +2120,6 @@
2105 2120
        _filename(fn) {
2106
      if (!(*_is)) throw IoError("Cannot open file", fn);
2121
      if (!(*_is)) {
2122
        delete _is;
2123
        throw IoError("Cannot open file", fn);
2124
      }
2107 2125
    }
... ...
@@ -2388,3 +2406,6 @@
2388 2406
      : _is(new std::ifstream(fn.c_str())), local_is(true) {
2389
      if (!(*_is)) throw IoError("Cannot open file", fn);
2407
      if (!(*_is)) {
2408
        delete _is;
2409
        throw IoError("Cannot open file", fn);
2410
      }
2390 2411
    }
... ...
@@ -2397,3 +2418,6 @@
2397 2418
      : _is(new std::ifstream(fn)), local_is(true) {
2398
      if (!(*_is)) throw IoError("Cannot open file", fn);
2419
      if (!(*_is)) {
2420
        delete _is;
2421
        throw IoError("Cannot open file", fn);
2422
      }
2399 2423
    }
Show white space 2 line context
... ...
@@ -465,3 +465,6 @@
465 465
        _skip_nodes(false), _skip_arcs(false) {
466
      if (!(*_os)) throw IoError("Cannot write file", fn);
466
      if (!(*_os)) {
467
        delete _os;
468
        throw IoError("Cannot write file", fn);
469
      }
467 470
    }
... ...
@@ -475,3 +478,6 @@
475 478
        _skip_nodes(false), _skip_arcs(false) {
476
      if (!(*_os)) throw IoError("Cannot write file", fn);
479
      if (!(*_os)) {
480
        delete _os;
481
        throw IoError("Cannot write file", fn);
482
      }
477 483
    }
... ...
@@ -1026,3 +1032,6 @@
1026 1032
        _skip_nodes(false), _skip_edges(false) {
1027
      if (!(*_os)) throw IoError("Cannot write file", fn);
1033
      if (!(*_os)) {
1034
        delete _os;
1035
        throw IoError("Cannot write file", fn);
1036
      }
1028 1037
    }
... ...
@@ -1036,3 +1045,6 @@
1036 1045
        _skip_nodes(false), _skip_edges(false) {
1037
      if (!(*_os)) throw IoError("Cannot write file", fn);
1046
      if (!(*_os)) {
1047
        delete _os;
1048
        throw IoError("Cannot write file", fn);
1049
      }
1038 1050
    }
... ...
@@ -1589,3 +1601,6 @@
1589 1601
      : _os(new std::ofstream(fn.c_str())), local_os(true) {
1590
      if (!(*_os)) throw IoError("Cannot write file", fn);
1602
      if (!(*_os)) {
1603
        delete _os;
1604
        throw IoError("Cannot write file", fn);
1605
      }
1591 1606
    }
... ...
@@ -1597,3 +1612,6 @@
1597 1612
      : _os(new std::ofstream(fn)), local_os(true) {
1598
      if (!(*_os)) throw IoError("Cannot write file", fn);
1613
      if (!(*_os)) {
1614
        delete _os;
1615
        throw IoError("Cannot write file", fn);
1616
      }
1599 1617
    }
0 comments (0 inline)