Description: fix bug 
 docker-ce (5:20.10.3-12) buster; urgency=low
 .
   * Version: 20.10.3-13
   * fix bug 
Author: wanghuaiqing <wanghuaiqing@loongson.com>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: 2022-05-09

--- lcf-utils-1.0.1/src/loongker-ce-20.10.3.orig/sources/engine/image/appcompose/appcompose.go
+++ lcf-utils-1.0.1/src/loongker-ce-20.10.3/sources/engine/image/appcompose/appcompose.go
@@ -83,10 +83,12 @@ func (ac *appcomposer) appcompose(imgid
 	}
 	chainid := baseimg.RootFS.ChainID()
 	datadir := ac.as.GetAppLayerDataDir(al.AppLayerID())
-	_, err = ac.lss[baseimg.OperatingSystem()].RegisterDir(datadir, al.DiffID(), al.Size(), chainid)
+	os := baseimg.OperatingSystem()
+	newlayer, err := ac.lss[os].RegisterDir(datadir, al.DiffID(), al.Size(), chainid)
 	if err != nil {
 		return
 	}
+	defer layer.ReleaseAndLog(ac.lss[os], newlayer)
 	topimg, err := ac.as.GetConfig(al.AppLayerID())
 	if err != nil {
 		return
--- lcf-utils-1.0.1/src/loongker-ce-20.10.3.orig/sources/engine/image/image.go
+++ lcf-utils-1.0.1/src/loongker-ce-20.10.3/sources/engine/image/image.go
@@ -181,6 +181,9 @@ func (img *Image) setdepdiff(index int,
 	if img.Config == nil {
 		return errors.New("container config of the image is empty")
 	}
+	if img.Config.Labels == nil {
+		img.Config.Labels = make(map[string]string)
+	}
 	img.Config.Labels["depdiff"+strconv.Itoa(index)] = id.String()
 	return nil
 }
@@ -192,6 +195,9 @@ func (img *Image) setdeplen(deplen int)
 	if img.Config == nil {
 		return errors.New("container config of the image is empty")
 	}
+	if img.Config.Labels == nil {
+		img.Config.Labels = make(map[string]string)
+	}
 	img.Config.Labels["deplen"]=strconv.Itoa(deplen);
 	return nil
 }
@@ -200,6 +206,9 @@ func (img *Image) SetLayerDiff(diffid la
 	if img.Config == nil {
 		return errors.New("container config of the image is empty")
 	}
+	if img.Config.Labels == nil {
+		img.Config.Labels = make(map[string]string)
+	}
 	img.Config.Labels["upgradelayer"+diffid.String()] = "true";
 	return nil
 }
