weston: modify buffer release flow [1/1]

PD#SWPL-181942

Problem:
weston crash when exit from youtube.

Solution:
modify buffer info only when buffer is valid.

Verify:
ah212

Change-Id: I386e4d0c4f8a2afba0ae5394beee7e232fa921ae
Signed-off-by: limin.tian <limin.tian@amlogic.com>
diff --git a/libweston/compositor.c b/libweston/compositor.c
index 1fd5954..27d2cea 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -3486,14 +3486,14 @@
 			wl_client_post_no_memory(client);
 			return;
 		}
+		buffer->surface = surface;
+		buffer->attach = buffer->attach+1;
 	}
 
 	/* Attach, attach, without commit in between does not send
 	 * wl_buffer.release. */
 	weston_surface_state_set_buffer(&surface->pending, buffer);
-	buffer->surface = surface;
 
-	buffer->attach = buffer->attach+1;
 	surface->pending.sx = sx;
 	surface->pending.sy = sy;
 	surface->pending.newly_attached = 1;