Skip to content

Commit e2f127c

Browse files
cjihriggeeksilva97
authored andcommitted
sqlite: fix coverity warnings related to backup()
This commit fixes several coverity warnings related to the recently landed backup() API. PR-URL: #56961 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 3bf3cdf commit e2f127c

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/node_sqlite.cc

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ class BackupJob : public ThreadPoolWork {
165165
env_(env),
166166
source_(source),
167167
pages_(pages),
168-
source_db_(source_db),
169-
destination_name_(destination_name),
170-
dest_db_(dest_db) {
168+
source_db_(std::move(source_db)),
169+
destination_name_(std::move(destination_name)),
170+
dest_db_(std::move(dest_db)) {
171171
resolver_.Reset(env->isolate(), resolver);
172172
progressFunc_.Reset(env->isolate(), progressFunc);
173173
}
@@ -308,7 +308,7 @@ class BackupJob : public ThreadPoolWork {
308308
sqlite3* dest_ = nullptr;
309309
sqlite3_backup* backup_ = nullptr;
310310
int pages_;
311-
int backup_status_;
311+
int backup_status_ = SQLITE_OK;
312312
std::string source_db_;
313313
std::string destination_name_;
314314
std::string dest_db_;
@@ -1106,8 +1106,14 @@ void Backup(const FunctionCallbackInfo<Value>& args) {
11061106

11071107
args.GetReturnValue().Set(resolver->GetPromise());
11081108

1109-
BackupJob* job = new BackupJob(
1110-
env, db, resolver, source_db, *dest_path, dest_db, rate, progressFunc);
1109+
BackupJob* job = new BackupJob(env,
1110+
db,
1111+
resolver,
1112+
std::move(source_db),
1113+
*dest_path,
1114+
std::move(dest_db),
1115+
rate,
1116+
progressFunc);
11111117
db->AddBackup(job);
11121118
job->ScheduleBackup();
11131119
}

0 commit comments

Comments
 (0)