You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by od...@apache.org on 2008/09/10 14:27:55 UTC

svn commit: r693814 - /harmony/enhanced/classlib/trunk/modules/print/src/main/native/print/windows/win_printer_factory.c

Author: odeakin
Date: Wed Sep 10 05:27:54 2008
New Revision: 693814

URL: http://svn.apache.org/viewvc?rev=693814&view=rev
Log:
Fix errors from HARMONY-5976:
 - Remove unnecessary dereference.
 - Return value of DocumentPropertiesW should be signed.
 - Fix potential memory leaks.

Modified:
    harmony/enhanced/classlib/trunk/modules/print/src/main/native/print/windows/win_printer_factory.c

Modified: harmony/enhanced/classlib/trunk/modules/print/src/main/native/print/windows/win_printer_factory.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/print/src/main/native/print/windows/win_printer_factory.c?rev=693814&r1=693813&r2=693814&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/print/src/main/native/print/windows/win_printer_factory.c (original)
+++ harmony/enhanced/classlib/trunk/modules/print/src/main/native/print/windows/win_printer_factory.c Wed Sep 10 05:27:54 2008
@@ -28,7 +28,7 @@
 static char * getFileName(const char * path) {
 	char * p = (char *) (path + strlen(path));
 
-	for (; p > path; *p--) {
+	for (; p > path; p--) {
 		if ((*p == '/') || (*p == '\\')) {
 			p++;
 			return p;
@@ -180,7 +180,7 @@
 JNIEXPORT jlong JNICALL Java_org_apache_harmony_x_print_WinPrinterFactory_getPrinterProps(JNIEnv * env, jclass c, jstring jprinterName, jlong handle) {
 	DEVMODEW * dm;
 	const unsigned short * printerName = (*env)->GetStringChars(env, jprinterName, NULL);
-	unsigned long dmSize = DocumentPropertiesW(NULL, JCAST(handle, HANDLE),
+	LONG dmSize = DocumentPropertiesW(NULL, JCAST(handle, HANDLE),
 			(unsigned short *) printerName, NULL, NULL, 0);
 
 	if (dmSize < 0) {
@@ -358,11 +358,13 @@
 	if ((result == NULL) || (points == NULL)) {
 		SetLastError(ERROR_NOT_ENOUGH_MEMORY);
 		handleLastError(__FUNCTION__,__FILE__ , __LINE__, env);
+        free(points);
 		return NULL;
 	}
 
 	if (getPrinterCapabilities(env, handle, DC_PAPERSIZE, points) == -1) {
 		handleLastError(__FUNCTION__, __FILE__, __LINE__, env);
+        free(points);
 		return NULL;
 	}
 
@@ -396,11 +398,15 @@
 	if ((result == NULL) || (buff == NULL) || (resolutions == NULL)) {
 		SetLastError(ERROR_NOT_ENOUGH_MEMORY);
 		handleLastError(__FUNCTION__,__FILE__ , __LINE__, env);
+        free(buff);
+        free(resolutions);
 		return NULL;
 	}
 
 	if (getPrinterCapabilities(env, handle, DC_ENUMRESOLUTIONS, buff) == -1) {
 		handleLastError(__FUNCTION__, __FILE__, __LINE__, env);
+        free(buff);
+        free(resolutions);
 		return NULL;
 	}