mynewt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject [2/2] incubator-mynewt-larva git commit: Close the file if error occurs during file upload.
Date Tue, 26 Jan 2016 00:39:35 GMT
Close the file if error occurs during file upload.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/80cd4fd9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/80cd4fd9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/80cd4fd9

Branch: refs/heads/master
Commit: 80cd4fd962ec73f5ca942c72dd48e36a4a65143a
Parents: 7381d78
Author: Marko Kiiskila <marko@runtime.io>
Authored: Mon Jan 25 16:38:36 2016 -0800
Committer: Marko Kiiskila <marko@runtime.io>
Committed: Mon Jan 25 16:38:36 2016 -0800

----------------------------------------------------------------------
 libs/imgmgr/src/imgmgr_fs.c | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/80cd4fd9/libs/imgmgr/src/imgmgr_fs.c
----------------------------------------------------------------------
diff --git a/libs/imgmgr/src/imgmgr_fs.c b/libs/imgmgr/src/imgmgr_fs.c
index cc5582f..529e801 100644
--- a/libs/imgmgr/src/imgmgr_fs.c
+++ b/libs/imgmgr/src/imgmgr_fs.c
@@ -222,6 +222,11 @@ imgr_file_upload(struct nmgr_jbuf *njb)
 
     if (len && imgr_state.upload.file) {
         rc = fs_write(imgr_state.upload.file, img_data, len);
+        if (rc) {
+            fs_close(imgr_state.upload.file);
+            imgr_state.upload.file = NULL;
+            return OS_EINVAL;
+        }
         imgr_state.upload.off += len;
         if (imgr_state.upload.size == imgr_state.upload.off) {
             /* Done */


Mime
View raw message