diff --git a/ole/ole2nls.c b/ole/ole2nls.c
index 51de301ff32a2824692a160542b290b038649b46..d288e58b54101ac56f93f603df2d492e705c5461 100644
--- a/ole/ole2nls.c
+++ b/ole/ole2nls.c
@@ -2400,7 +2400,10 @@ INT WINAPI GetNumberFormatA(LCID locale, DWORD dwflags,
     if (cchNumber!=0)
     {
         memcpy( lpNumberStr, sDestination, min(cchNumber, retVal) );
-        if (cchNumber < retVal) retVal = 0;
+        if (cchNumber < retVal) {
+            retVal = 0;
+            SetLastError(ERROR_INSUFFICIENT_BUFFER);
+        }
     }
     return retVal;
 }
@@ -2653,7 +2656,10 @@ INT WINAPI GetCurrencyFormatA(LCID locale, DWORD dwflags,
     if (cchCurrency)
     {
         memcpy( lpCurrencyStr, pDestination, min(cchCurrency, retVal) );
-        if (cchCurrency < retVal) retVal = 0;
+        if (cchCurrency < retVal) {
+            retVal = 0;
+            SetLastError(ERROR_INSUFFICIENT_BUFFER);
+        }
     }
     return retVal;
 }