Added error check for output buffer size. am: 3f6c941de5 am: f0d2caa214 am: 9a6312ec9f am: 83c397d1ab am: 462316f8d2 am: 564bdc7609 am: 3aa85a9cc5 am: 873d325720 am: 08d268a942 am: 2e10678938
am: 7c079d36e9

Change-Id: I326a295d75dc840b18bf4f45e5df530ec5ffcd5d