Download raw body.
fix use of uninitialized variable in update_blob
On Tue, Feb 13, 2024 at 08:18:57PM +0100, Omar Polo wrote: > both update_timestamps may be used un-initalized. You mean in the case where status is something other than add/modify/delete and S_ISLNK(te->mode)) is true and ie is NULL? I am not sure when this combination of conditions will happen in practice. But initializing to 0 is probably the right thing to do in any case. > Where here, do what I > should have done in ef6234452a and remove the nested update_timestamps. Yes, makes sense. ok > spotted by smatch. > > ok? > > diff -s /home/op/w/got > commit - 06bd8ee415aa89adaeb49825ad96dfe83554b77e > path + /home/op/w/got (staged changes) > blob - 866c19c894b29dffe0ffd1be3cbc2f6999ed8db4 > blob + fc674d163162822cb326fcd1144a79b40778c452 > --- lib/worktree.c > +++ lib/worktree.c > @@ -1920,7 +1920,7 @@ update_blob(struct got_worktree *worktree, > unsigned char status = GOT_STATUS_NO_CHANGE; > struct stat sb; > int fd1 = -1, fd2 = -1; > - int update_timestamps; > + int update_timestamps = 0; > > if (asprintf(&ondisk_path, "%s/%s", worktree->root_path, path) == -1) > return got_error_from_errno("asprintf"); > @@ -2044,7 +2044,6 @@ update_blob(struct got_worktree *worktree, > goto done; > > if (status == GOT_STATUS_MODIFY || status == GOT_STATUS_ADD) { > - int update_timestamps; > struct got_blob_object *blob2 = NULL; > char *label_orig = NULL; > if (got_fileindex_entry_has_blob(ie)) { > >
fix use of uninitialized variable in update_blob