Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxiaoquan233 committed May 10, 2020
1 parent 2fdc8b9 commit 8b42a86
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/include/Client/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class Client : public base
{
private:
File* file;
File* file = nullptr;
pkt_load* data = nullptr;
sockaddr_in serv_addr_cmd;
sockaddr_in serv_addr_data;
Expand Down
1 change: 1 addition & 0 deletions src/src/Client/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ int Client::recv_cmd(char* buf, int len, int usec)

bool Client::send_file(const char* input_file_name, int path_offs)
{
if (file) file->~File();
file = new File(input_file_name, MAX_PACKET_DATA_BYTE_LENGTH, 0);
char* cmd = nullptr;
cmd = new char[MAX_PACKET_DATA_BYTE_LENGTH];
Expand Down
11 changes: 10 additions & 1 deletion src/src/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <string.h>
#include <sys/stat.h>
#include <iostream>
#include <errno.h>
#include "../include/file.h"

using namespace std;
Expand All @@ -29,7 +30,15 @@ File::File(const char* input_file, int pkt_len, int offset)
base_offset = offset;
}

File::~File(){}
File::~File()
{
if (file_ptr)
fclose(file_ptr);
if (send_rec)
delete[]send_rec;
if (file_path)
delete[]file_path;
}

int File::get_tot_num()
{
Expand Down

0 comments on commit 8b42a86

Please sign in to comment.